我怎样才能改变这种代码的多行的更新工作。@ id为int和ORDER_ID是主键,但我要检查每一个已status_b =行'套袋多行更新
select @id=inserted.order_id from inserted;
if update(status_b)
begin
if (select status_b from inserted)='bagged'
begin
if (select o.id
from [order] o
left join [print] p on o.id=p.order_id
left join [laminate] l on l.order_id=o.id
left join [slitting] s on s.order_id=o.id
left join [bagging] b on b.order_id=o.id
where
1=(case when (o.printing='دارد' and status_p='printed') or o.printing='ندارد' then 1 end)
and 1=(case when (o.lamination='دارد' and status_l1='laminated') or o.lamination='ندارد' then 1 end)
and 1=(case when (o.lamination='دارد' and l.layer2<>'' and status_l2='laminated2') or o.lamination='ندارد' then 1 end)
and 1=(case when (o.coldseal='دارد' and status_c='coldsealed') or o.coldseal='ندارد' then 1 end)
and 1=(case when (o.slitting='دارد' and status_s='slitted') or o.slitting='ندارد' then 1 end)
and 1=(case when (o.bagging='دارد' and status_b='bagged') or o.bagging='ندارد' then 1 end)
and [email protected]) is not null
begin
update [order] set [status]='finished' where [email protected]
end
end
end
你应该在WHERE子句 – MtwStark
上添加C.STATUS_B ='BAGGED' c.oid不是'b.oid',装入左边的连接为b 3行后面和'c.status_b ='bagged'在where子句@KumarHarsh –