I am not the smartest on the list, but I think this would do it for you. UPDATE table_one t1, table_two t2 SET t1.ID = t2.ID WHERE t2.num = t1.num AND t1.ID = 0
J.R. -----Original Message----- From: C.F. Scheidecker Antunes [mailto:[EMAIL PROTECTED] Sent: Sunday, October 16, 2005 1:45 PM To: mysql@lists.mysql.com Subject: SQL statement help Importance: High Hello All, I have two MySQL 4.1 tables. The first table has an ID field which is set to zero. The second one has ID fields and filenames. I need a single SQL statement to set the ID from table 1 to the ID from table 2 ONLY IF the ID on one is zero. That is, if the ID on table one is not set (still equal to zero), grab the ID from table2 where the num of table2 is equal to table1. table one - Title - num - ID (set to zero initially) table two - num - ID - filename SET table1.ID = <someID> if table1.ID EQUAL to zero. Set the ID on table1 from the table 2 where the num on table 2 equals the num on table1 only if the ID on table 1 is zero. Thank you in advance, C.F. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
smime.p7s
Description: S/MIME cryptographic signature