table 1 :
表1:
idtb1 --pk published delete
table 2 :
表2:
idtb2 --pk idtb1 --fk published delete
how to update 2 column published
,delete
on 2 table together by command Update
如何通过命令更新2列发布、2表上一起删除
1 个解决方案
#1
4
You can't update more than one table in a single statement
不能在一条语句中更新多个表
BEGIN TRANSACTION
update A
set A.published = @published
from table1 A
inner join table2 B on B.idtb1 = A.idtb1
update B
set B.published = @published
from table2 B
inner join table1 A on B.idtb1 = A.idtb1
COMMIT
This question already has an answer here
这个问题已经有答案了。
#1
4
You can't update more than one table in a single statement
不能在一条语句中更新多个表
BEGIN TRANSACTION
update A
set A.published = @published
from table1 A
inner join table2 B on B.idtb1 = A.idtb1
update B
set B.published = @published
from table2 B
inner join table1 A on B.idtb1 = A.idtb1
COMMIT
This question already has an answer here
这个问题已经有答案了。