Mysql – Appending data
Jul 10, 2007 mysql, techno-babble
Problem:
Appending data from one table to another table where duplicate might exist.
Solution:
A simple “Insert into table2 select * from table1″ query will give errors saying “duplicate records exist”, to go around it, the following query should do the job:
INSERT INTO MASTERTABLE
SELECT *
FROM NEWTABLE
WHERE NEWTABLE.`UNIQUEID` NOT
IN (SELECT `UNIQUEID`
FROM MASTERTABLE
)




Leave a Reply
You must be logged in to post a comment.