Update record using 'EXISTS'

Database

Update record using 'EXISTS'

Hi,

I have a table which stores toekn id and record id. One token can have multiple record ids associated with it. 

I have created second table which has 3 columns, token1, token2 and merge_flag.

Need to update merge flag to "Y" if record set for token1 matches that of token2.

I used the following SQL but it gives error 3807 (Object 'a' does not exist)

UPDATE  a
FROM token_match_table a
SET merge_flag = 1
WHERE
EXISTS
((SEL row_d FROM token_data_table WHERE token_d = a.token_id1
MINUS ALL
SEL row_d FROM token_data_table WHERE token_d = a.token_id2)
UNION ALL
(SEL row_d FROM token_data_table WHERE token_d = a.token_id2
MINUS ALL
SEL row_d FROM token_data_table WHERE token_d = a.token_id1))
;

Thanks in advance.

/Kiran Marathe


Tags (1)