tanhaaiyaaN

Notes from the underground!

Mysql – Appending data

Written By: tanhaa - Jul• 10•07

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

)

Share

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>