0

I have a values in table "REVIEW" that need to change REVIEW_STATUS from "UNDER_REVIEW" to "Abstain" based upon other records in the table that have the same REFERENCE_NUMBER , A specific REVIEW_TYPE and that REVIEW_STATUS is "ABSTAIN". The I have a sample set up in SQL Fiddle

http://sqlfiddle.com/#!2/8227f/1

I am able to query the tables for the records, but I am having difficulty getting the update query correct.

-- 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' )
;  

Your help is appreciated! Thank you!

4

2 回答 2

2

改变

UPDATE TABLE REVIEW AS REV1 
...

UPDATE REVIEW AS REV1 
...

更新了 SQLFiddle

于 2013-05-10T21:52:26.890 回答
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' )
; 
于 2013-05-10T21:53:07.953 回答