Page 1 of 1

MySQL Problem

Posted: Tue Aug 17, 2004 6:41 pm
by mattmcb
Can someone tell me the correct syntax for this query:

Code: Select all

UPDATE products SET products.cat = cat2.cat_desc WHERE cat2.id = products.cat

Posted: Tue Aug 17, 2004 6:48 pm
by feyd

Code: Select all

UPDATE products,cat2 SET products.cat = cat2.cat_desc WHERE cat2.id = products.cat
Starting with MySQL 4.0.4, you can also perform UPDATE operations that cover multiple tables:

Code: Select all

UPDATE items,month SET items.price=month.price
WHERE items.id=month.id;
The example shows an inner join using the comma operator, but multiple-table UPDATE statements can use any type of join allowed in SELECT statements, such as LEFT JOIN.