updating duplicate rows
i wa开发者_如何学编程nt to change 'aa' to 'bb' and 'bb' to 'aa'
col1 col2
---- ----
1 aa
2 bb
3 aa
4 aa
5 bb
is it possible with single update statement? i know it is possible with some temp table or variable
For example:
UPDATE your_table_name SET
col2=CASE WHEN col2='aa' THEN 'bb'
WHEN col2='bb' THEN 'aa'
ELSE col2
END
精彩评论