How can I use CASE
in a MySQL query? I'd like to perform something like this, where the value of one column on the table/view is used to create another column in the result set.
I don't know the correct syntax. How can this be done?
SELECT CASE WHEN sex = 1 THEN 'Boy' ELSE THEN 'Girl' sex
FROM user