alex alex - 2 years ago 88
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


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 Source
SELECT CASE WHEN bool_value <> 0 THEN "yes" ELSE "no" END
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download