我在表“REVIEW”中有一个值需要根据表中具有相同REFERENCE_NUMBER,特定REVIEW_TYPE和REVIEW_STATUS为“ABSTAIN”的其他记录将REVIEW_STATUS从“UNDER_REVIEW”更改为“Abstain”。我在SQL Fiddle
中设置了一个示例http://sqlfiddle.com/#!2/8227f/1
我能够在表中查询记录,但是我很难获得更新查询。
-- run
UPDATE TABLE REVIEW AS REV1
LEFT JOIN REVIEW AS REV2
ON (REV1.REFERENCE_NUMBER=REV2.REFERENCE_NUMBER)
SET REV1.REVIEW_STATUS='ABSTAIN'
WHERE
REV1.REVIEW_TYPE ='QOC'
AND
REV1.REVIEW_STATUS='UNDER_REVIEW'
AND
REV2.REVIEW_TYPE ='MED_NEC'
AND (REV2.REVIEW_STATUS ='ABSTAIN' )
;
非常感谢您的帮助!谢谢!
答案 0 :(得分:2)
答案 1 :(得分:0)
这是单词TABLE
UPDATE REVIEW AS REV1
LEFT JOIN REVIEW AS REV2
ON (REV1.REFERENCE_NUMBER=REV2.REFERENCE_NUMBER)
SET REV1.REVIEW_STATUS='ABSTAIN'
WHERE
REV1.REVIEW_TYPE ='QOC'
AND
REV1.REVIEW_STATUS='UNDER_REVIEW'
AND
REV2.REVIEW_TYPE ='MED_NEC'
AND (REV2.REVIEW_STATUS ='ABSTAIN' )
;