Reputation: 11
Can we update a data in multiple tables with one query?
UPDATE table1, table2
SET table1.column_name = values,
table2.column_name = values
WHERE
table1.column_name = values
AND table2.column_name = values
Is this query correct?
Upvotes: 1
Views: 40
Reputation: 6568
No you can not and you should write two separate Update statement. But in order to make sure that the both Updates are executed successfully, you can put them inside a transaction.
Upvotes: 3