开发者

Insert Query for table

How to add data from one table to another table with new data in SQ开发者_如何学CL?


You'd use an SQL INSERT INTO SELECT like so:

INSERT INTO "table1" ("column1", "column2", ...)
SELECT "column3", "column4", ...
FROM "table2"

You can find more info here: http://www.1keydata.com/sql/sqlinsert.html


Don't have enough points to comment, but lomaxx's query is functioning correctly @shanks. If you run an insert query again, you will get duplicates for each time the query is run.


INSERT INTO "table1" ("column1", "column2", ...)
SELECT "column3", "column4", ...
FROM "table2"
minus
SELECT "column1", "column2", ...
FROM "table1"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜