输出“是/否”。而不是“ t / f” PostgreSQL中的布尔数据类型 [英] Output "yes/no" instead of "t/f" for boolean data type in PostgreSQL

查看:93
本文介绍了输出“是/否”。而不是“ t / f” PostgreSQL中的布尔数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何进行查询以返回是/否而不是 t / f (是/否) )?

How do I make a query that would return yes/no instead of t/f (true/false)?

当前解决方案是:

SELECT credit_card_holders.token IS NOT NULL AS premium

我找到了一个Ruby解决方案:
轨道(或Ruby):是/否,而不是True / False

I found a Ruby solution: Rails (or Ruby): Yes/No instead of True/False

但如果可能的话,宁愿在PostgreSQL中执行。

But would rather do it in PostgreSQL if possible.

推荐答案

此:

(case when credit_card_holders.token IS NOT NULL then 'Yes' else 'No' end) AS premium

这篇关于输出“是/否”。而不是“ t / f” PostgreSQL中的布尔数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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