表A,字段1
表B,字段1
如何一条sql更新两张表?
设置字段1=100,字段2=200
update 表A,表B,set 表A.字段1......这样吗?
迷茫2017-04-17 15:36:06
UPDATE table1 AS a, table2 AS b, table3 AS c, ...
SET a.name = 'W', b.name = 'T', c.name = 'F', ...
WHERE a.id = 1 AND b.id = 2 AND c.id = 3
However, it is not recommended to perform update
operations on two tables with unrelated requirements in one SQL.
PHP中文网2017-04-17 15:36:06
It is recommended to start a transaction to complete the update operation of the two tables.
start transaction;
update table A;
update table B;
commit;