如何从MySQL中的布尔类型返回不同的字符串? [英] How to return different strings from a Boolean type in MySQL?
本文介绍了如何从MySQL中的布尔类型返回不同的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在MySql中将某列设置为布尔值,则查询将返回值为0
或1
.
If I have a column set up as Boolean in MySql, a query returns the value as either 0
or 1
.
是否可以做这样的事情
SELECT `bool_value` AS "yes" OR "no"
我的意思是,根据是真还是假返回两个不同的字符串.
What I mean is, return two different strings based on whether it is true or false.
推荐答案
SELECT CASE WHEN bool_value <> 0 THEN "yes" ELSE "no" END
这篇关于如何从MySQL中的布尔类型返回不同的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文