MySQL,如何用一条sql来update两张表?
巴扎黑
巴扎黑 2017-04-17 15:34:06
0
4
702

表A,字段1
表B,字段1
如何一条sql更新两张表?
设置字段1=100,字段2=200
update 表A,表B,set 表A.字段1......这样吗?

巴扎黑
巴扎黑

reply all(4)
迷茫
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.

Ty80

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;

大家讲道理

Why not give it a try?

迷茫

Such an amazing idea

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template