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.
MySQL doesn't really have booleans. TRUE and FALSE are aliases to 1 and 0, and the BOOL column type is just an alias for TINYINT(1) . All expressions that appear to give boolean results actually return 0 or 1.
MySQL does not have a boolean (or bool) data type. Instead, it converts boolean values into integer data types (TINYINT). When you create a table with a boolean data type, MySQL outputs data as 0, if false, and 1, if true.
You can update boolean value using UPDATE command. If you use the BOOLEAN data type, MySQL internally convert it into tinyint(1). It can takes true or false literal in which true indicates 1 to tinyint(1) and false indicates 0 to tinyint(1).
In MySQL, TINYINT(1) and boolean are synonymous. Because of this, the MySQL driver implicitly converts the TINYINT(1) fields to boolean if the the Java tinyInt1isBit configuration property is set to true (which is the default) and the storage size is 1. Stitch then interprets these columns as BIT(1)/boolean .
SELECT CASE WHEN bool_value <> 0 THEN "yes" ELSE "no" END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With