SQL 选择布尔选项

发布于 2025-01-05 06:13:14 字数 460 浏览 3 评论 0原文

抱歉,标题含糊不清,但我不确定如何用一句话来解释我想做什么。

序言: 选择布尔列的 SQL 语法如下:

SELECT MyBooleanColumn FROM MyTableThatHasABooleanColumn

这会产生以下结果:

MyBooleanColumn
===============
       1
       1
       1
       0
       1
      ...

问题: 有没有办法获得以下结果?

MyBooleanColumn
===============
     True
     True
     True
     False
     True
      ...

Sorry for the vague title, but I'm not exactly sure how I can explain what I want to do in a sentence.

Preamble: The SQL syntax for selecting columns that are Boolean is as follows:

SELECT MyBooleanColumn FROM MyTableThatHasABooleanColumn

This produces the following result:

MyBooleanColumn
===============
       1
       1
       1
       0
       1
      ...

Question: Is there a way to get the following result instead?

MyBooleanColumn
===============
     True
     True
     True
     False
     True
      ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小…红帽 2025-01-12 06:13:15

是的,这样做:

SELECT 
case when MyBooleanColumn = 1 then 'True' else 'False' end as MyBooleanColumn 
FROM MyTableThatHasABooleanColumn

Yes, do it like this:

SELECT 
case when MyBooleanColumn = 1 then 'True' else 'False' end as MyBooleanColumn 
FROM MyTableThatHasABooleanColumn
末蓝 2025-01-12 06:13:15
SELECT case when MyBooleanColumn = 1 then 'True' else 'False' end as MyBooleanColumn  
FROM MyTableThatHasABooleanColumn
SELECT case when MyBooleanColumn = 1 then 'True' else 'False' end as MyBooleanColumn  
FROM MyTableThatHasABooleanColumn
如此安好 2025-01-12 06:13:14
SELECT case 
        when MyBooleanColumn = 1 then 'True' 
        else 'False' 
    end as MyBooleanColumn  
FROM MyTableThatHasABooleanColumn 
SELECT case 
        when MyBooleanColumn = 1 then 'True' 
        else 'False' 
    end as MyBooleanColumn  
FROM MyTableThatHasABooleanColumn 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文