b00*_*il' 11 sql postgresql boolean
下面的比较有区别吗
#1
where x = true
Run Code Online (Sandbox Code Playgroud)
#2
where x is true
Run Code Online (Sandbox Code Playgroud)
#3
where x = '1'
Run Code Online (Sandbox Code Playgroud)
#4
where x
Run Code Online (Sandbox Code Playgroud)
Lau*_*lbe 12
这与
\nWHERE x\nRun Code Online (Sandbox Code Playgroud)\n是的TRUE,FALSE或者NULL确切地说,是在什么时候x是。
这与第一种情况相同,除了当x为 NULL 时,在这种情况下它将是FALSE。所以它是一样的
WHERE coalesce(x, FALSE)\nRun Code Online (Sandbox Code Playgroud)\n这恰好与第一种情况相同,因为\'1\'被解释为TRUE。查看文档:
\n\ntype 的数据类型输入函数
\nboolean接受 \xe2\x80\x9ctrue\xe2\x80\x9d 状态的这些字符串表示形式:\n
true
\nyes
\non
\n1
我首选的方法是最简单的:
\nWHERE x\nRun Code Online (Sandbox Code Playgroud)\n