Wednesday, August 2, 2017

Mysql Query for swapping value in same column of table

UPDATE tablename SET fieldname  = CASE
    WHEN fieldname  = 'Y' THEN 'N'
    WHEN fieldname   = 'N' THEN 'Y'
    ELSE fieldname
    END
WHERE fieldname  in ('Y','N')

No comments:

Post a Comment