We can use the functions CASE .. WHEN ... to map integer to text string in mysql

The example query is as shown below

SELECT *, CASE type WHEN 1 THEN 'Enabled' WHEN 2 THEN 'Disabled' END as status
FROM users

You can also use the ELSE clause to specify a default,
e.g.

CASE type WHEN 1 THEN 'Enabled' WHEN 2 THEN 'Disabled' ELSE 'Pending' END.

Leave a Reply

Your email address will not be published. Required fields are marked *