Reputation: 9
How to add data from one table to another table with new data in SQL?
Upvotes: 0
Views: 62
Reputation: 16677
INSERT INTO "table1" ("column1", "column2", ...)
SELECT "column3", "column4", ...
FROM "table2"
minus
SELECT "column1", "column2", ...
FROM "table1"
Upvotes: 0
Reputation: 1742
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.
Upvotes: 0
Reputation: 115773
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
Upvotes: 1