我有两个表,它们的值是
lot-master
:
event-id lotid status
1 1 Awarded
1 2 Awarded
1 3 Awarded
和event-master
:
event-id status
1 Open
如果已授予所有lot-master
状态,则使用event-master
查询更新update
状态。
答案 0 :(得分:2)
如果您想这样做,那么您可以尝试这样做,
DECLARE @Count AS INT = 0,
@ConditionCount INT = 0
SELECT @Count = COUNT(1) FROM lot-MASTER
SELECT @ConditionCount = COUNT(1) FROM lot-MASTER WHERE STATUS = 'Awarded'
IF (@ConditionCount = @Count)
BEGIN
UPDATE EVENT-MASTER
SET STATUS = 'Awarded'
END