我试图更新我的产品中的产品'其他2个表中没有的表。这些产品有一个独特的标识符' ean'。我的计划是与其他表进行2次左连接,然后更新其他ean字段是否包含null。顺便使用MS SQL Server。
表:product,table2,table3
update product
set published = 0
from p as product
left join a as table2
on p.ean = a.ean
left join t as table3
on p.ean = t.ean
where t.ean is null and a.ean is null
既然它似乎不起作用,我做错了什么?
答案 0 :(得分:0)
我认为问题在于您的别名。
如果您的表格为product, table2, table3
,则您的查询应为:
update P
set published = 0
from product as P
left join table2 as A
on P.ean = A.ean
left join table3 as T
on P.ean = T.ean
where T.ean is null and A.ean is null