MySQL:返回“0"&“1"而不是“假"&“真实" [英] MySQL: return "0" & "1" rather than "false" & "true"
本文介绍了MySQL:返回“0"&“1"而不是“假"&“真实"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要返回 true
或 false
而不是 1
&0
,使用以下查询:
I need to return true
or false
rather than 1
& 0
, using following query:
select if(u.id is null,false,true) status
from user u
limit 10
上面的查询返回 status
值为 0 或 1 而不是 true
和 false
,
the above query returns status
with value 0 or 1 rather than true
and false
,
有什么办法可以解决这个问题吗?
Is there any way to fix this?
推荐答案
如果需要,您可以将值作为字符串返回:
If you want, you can return the values as strings:
SELECT IF(u.id IS NULL, 'false', 'true') as status
FROM user u
LIMIT 10
这篇关于MySQL:返回“0"&“1"而不是“假"&“真实"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文