mysql case when update code example
Example 1: update using case in mysql
UPDATE `table` SET `uid` = CASE
WHEN id = 1 THEN 2952
WHEN id = 2 THEN 4925
WHEN id = 3 THEN 1592
ELSE `uid`
END
WHERE id in (1,2,3)
Example 2: mysql case when on date
SELECT
id,
CASE
WHEN date_activated > '2011-11-23 18:30:00' THEN 'after'
WHEN date_activated > '2010-01-20 00:00:00' THEN 'before'
ELSE 'not yet'
END AS date_note
FROM table1;