How to update multiple tables by single mysql query?

database, mysql

Solution

Try this:

UPDATE table_1 tb1, 
       table_2 tb2, 
       table_3 tb3 
SET    tb1.field2 = "some value", 
       tb2.field3 = "some other value", 
       tb3.field4 = "some another value" 
WHERE  tb1.field1 = tb2.field1 
       AND tb1.field1 = tb3.field1 
       AND tb1.field1 = "value" 

I tested the code on MSAccess and SQL SERVER 2008

Problem

I have two tables tb1 & tb2 I have to update a common column of both tables, i.e user_level I have a common criteria for both tables like username. So I want to update like this: ``` UPDATE tb1, tb2 SET user_level=1 WHERE username="Mr.X" ``` But somehow it is not working. What would be the correct mysql query for this?

Original source