Jump to content

Recommended Posts

I have a mysql table with the name of the fruit as primary key. If I'm given a new table with NEW names of fruits, I want those to go into my table. However, if the primary key (the fruit) already exists in my first table, I don't want it updated.

 

For example:

 

Table 1:

apple red

olive green

 

 

Table 2:

olive black

lemon yellow

 

Since table 1 already has an olive, I don't want the olive from table 2 inserted (even though it's a different color), but I want the lemon inserted into table 1

 

What is the correct mysql syntax, please? Thank you!!

Link to comment
https://forums.phpfreaks.com/topic/270575-mysql-update-question/
Share on other sites

Hi, thank you for your quick response! Would you mind explaining the stuff I need to type before the "insert ignore" part? I know it will be select into or union or join or something. I have been trying to research this online but I guess I'm feeling kind of dumb today :-) Would it be something like

 

insert ignore into Original_Table

(select * from New_Table where

New_Table.fruit != Original_Table.fruit);

 

Thank you!!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.