alex alex - 5 months ago 10
MySQL Question

How to return different strings from a Boolean type in MySQL?

If I have a column set up as Boolean in MySql, a query returns the value as either

0
or
1
.

Is it possible to do something like this

SELECT `bool_value` AS "yes" OR "no"


What I mean is, return two different strings based on whether it is true or false.

Answer
SELECT CASE WHEN bool_value <> 0 THEN "yes" ELSE "no" END
Comments