gpt4 book ai didi

sql - 这是在 SQL 中进行 bool 测试的正确方法吗?

转载 作者:行者123 更新时间:2023-12-03 05:27:14 25 4
gpt4 key购买 nike

假设 active 是一个“ bool 字段”(小整数,0 或 1)

-- Find all active users
select * from users where active

-- Find all inactive users
select * from users where NOT active

换句话来说,“NOT”运算符可以直接应用于 bool 字段吗?

最佳答案

SQL 中的 bool 值是一个位字段。这意味着 1 或 0。正确的语法是:

select * from users where active = 1 /* All Active Users */

select * from users where active = 0 /* All Inactive Users */

关于sql - 这是在 SQL 中进行 bool 测试的正确方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/859762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com