Welcome to my blog, hope you enjoy reading
RSS

Saturday 13 July 2013

MySQL: Update multiple tables with multiple columns

MySQL: Update multiple tables with multiple columns

Table1







Table2






problem:
update name and productname in table1 and table2 at a time.

Query:
UPDATE `table1` as t1 join `table2` as t2 on t1.id=t2.productid SET t2.`productname`='changeproduct',t1.name='changeitem' WHERE t1.id=1

0 comments: