I have 5 tables. how to update one data that check if this data has not already exist in all the 5 tables.
I know something like INSERT ... ON DUPLICATE KEY UPDATE, but not find an example for multi-tables.
Now I use some poor query like:
mysql_query("UPDATE table1 SET image = '' WHERE image = '".$image."' ");
mysql_query("UPDATE table2 SET image = '' WHERE image = '".$image."' ");
mysql_query("UPDATE table3 SET image = '' WHERE image = '".$image."' ");
mysql_query("UPDATE table4 SET image = '' WHERE image = '".$image."' ");
mysql_query("UPDATE table5 SET image = '' WHERE image = '".$image."' ");
mysql_query("UPDATE table1 SET image = '".$image."' WHERE id = '".$id."'");
First update empty value for each table where the data is DUPLICATE then insert the value. this will cost more mysql connects I think… So how to use less query do this update? Thanks.
EDIT1: tried something below, it will update the value ignore to check if the value has already exited in one table of the five.
mysql_query("
UPDATE table1,table2,table3,table4,table5
SET table1.image='".$image."'
WHERE table1.id='".$id."'
AND table1.image!='".$image."'
AND table2.image!='".$image."'
AND table3.image!='".$image."'
AND table4.image!='".$image."'
AND table5.image!='".$image."'
");
ok, i think this is what you asked for