是否可以对一个查询进行以下两个查询?
update customers set customer_name = 'John' where customer_id=1;
update purchases set state='Accepted' where customer_id=1;
customer
(表)
customer_id(PK)
customer_name
purchases
(表)
customer_id(FK)
product
state
由于
答案 0 :(得分:0)
您可以在一个交易中执行它们:
START TRANSACTION;
update customers set customer_name = 'John' where customer_id=1;
update purchases set state='Accepted' where customer_id=1;
COMMIT;
如果事务中的某些内容失败,则所有更改都将回滚