querybuilder icon indicating copy to clipboard operation
querybuilder copied to clipboard

Select * INTO x from Y

Open jimsandersonuk opened this issue 6 years ago • 3 comments

Can we have a statement that allows us to insert into a temp table using the sql standard INTO?

All other statements seem to be available but this, and hand-coding this goes against the use-case for Kata.

cheers,

Jim

jimsandersonuk avatar Mar 19 '19 01:03 jimsandersonuk

No, currently you can use the db.Statement() method, but it's nice to have, can you provide a full example, on how it should be implemented on multiple dbs? so you can speed up the process a bit

ahmad-moussawi avatar Mar 19 '19 07:03 ahmad-moussawi

Hi, In SQL Server, you can do this

SELECT * into equipments_backup FROM test where id = 2

Postgres SQL SELECT * INTO films_recent FROM films WHERE date_prod >= '2002-01-01';

MySQL,SQLLite 'CREATE TABLE equipments_backup AS SELECT * FROM test where id = 2 '

in sqlKata, can do something like db.Query("Books").WhereTrue("IsPublished").Into("NewTableName")

mawroos avatar Mar 12 '20 03:03 mawroos

yes it's a very useful statement, I came here searching about "how to in sqlkata" ... I'll try a different solution for my process

rolivares avatar Nov 15 '22 18:11 rolivares