I am trying to write MySQL query if else for this table,
table name: users
user_id | username | password | status
1 | john | 1 | 1
2 | jessi | 2 | 0
3 | mark | 1 | 2
status: 1 - enable, 0 - disable, 2 - deleted
I wrote SQL to get status data :
SELECT username, user_id, IF( STATUS =1, 'Enable', 'Disable' ) AS user_status
FROM `users`
how to write MySQL if elseif else statement for get all three status
CASECASE WHEN STATUS = 1 THEN 'Enable' WHEN STATUS = 0 THEN 'Disable' WHEN STATUS = 2 THEN 'Deleted' ELSE 'Unknown Status' END