Can I update two identical tables with one query?
TABLEA
_____________________________
| id | value |
|_____________|_____________|
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
|_____________|_____________|
TABLEB
_____________________________
| id | value |
|_____________|_____________|
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
|_____________|_____________|
I want to update both tables (SET value = 'z' WHERE id=3) at the same time.
Is this possible?
-Thanks
MySQL supports multiple-table updates using the following syntax:
Test case:
Result:
UPDATE:
If you prefer not to repeat the value you are going to set twice, you may want to use the following trick: