Alex Rivera | Logout

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

Asked 2010-07-29T03:53:19.530
24

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.

Edit
Report

1 Answer

36
SELECT CASE WHEN bool_value <> 0 THEN "yes" ELSE "no" END
answered 2010-07-29T03:55:38.877

Your Answer