MySQL:返回“0"&“1"而不是“假"&“真实" [英] MySQL: return "0" & "1" rather than "false" & "true"

查看:69
本文介绍了MySQL:返回“0"&“1"而不是“假"&“真实"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要返回 truefalse 而不是 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 而不是 truefalse

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆