我有以下子查询,如果订单详细信息状态中的所有项目= 2,则更新订单标题,但是我也有一些StatusFK = 4(已删除)的记录如何将其添加到我的子查询中以便它忽略任何StatusFK的4?
UPDATE tblOrder
SET tblOrder.Statusfk = 2
WHERE NOT EXISTS (SELECT 1
FROM tblOrderDetail
WHERE tblOrderDetail.OrderFK = tblOrder.OrderPK AND
tblOrderDetail.StatusFK <> 2 AND
tblOrder.StatusFK);
答案 0 :(得分:0)
UPDATE tblOrder SET tblOrder.Statusfk = 2
WHERE (((Exists (SELECT 1
FROM tblOrderDetail
WHERE tblOrderDetail.OrderFK = tblOrder.OrderPK AND
tblOrderDetail.StatusFK <> 2 AND
tblOrder.StatusFK AND tblOrderDetail.StatusFK <> 4
))=False));