Jump to content

Mysql Update Question


Carrie1956

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!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.