MySQL Forums
Forum List  »  Newbie

How to merge primary/foreign keys
Posted by: ashfh SDFLSDJfdjiee
Date: September 24, 2013 02:31PM

I have a db with 2 tables. eBayDD_Main & eBayDD_History. eBayDD_Main has an ID field and eBayDD_History has it's own ID field as well as a mainID field.


I want a SQL command that merges the two. If an ID appears in eBayDD_Main.ID, but does not appear in eBayDD_History.mainID then I would like to insert it into eBayDD_History.

It seems easy enough, but I don't quite have it... The select works fine, but I can't wrap my mind around merging them.

SELECT id FROM `eBayDD_Main` WHERE `id` NOT IN (SELECT mainID FROM `eBayDD_History`) LIMIT 1;

Options: ReplyQuote


Subject
Written By
Posted
How to merge primary/foreign keys
September 24, 2013 02:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.