Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sql选择条件,如果col1为空,则检查col2_Sql_Sqlite_Select_Ifnull - Fatal编程技术网

sql选择条件,如果col1为空,则检查col2

sql选择条件,如果col1为空,则检查col2,sql,sqlite,select,ifnull,Sql,Sqlite,Select,Ifnull,如何在SQL中实现以下功能。(我无法检查col1是否为空,检查col2是否为“已确认”) 从表1中选择数据,其中col1=“true”或(如果col1为空,请选中col2=“confirmed”) (检查col1和col2的值不同)假设col2为非空。如果可以是null,则展开条件(与所示条件类似) 哎呀。。。我正在使用sqlite。谢谢你的回答。但是,我用sqlite尝试过,它不起作用。它只需要第一个条件。输出仅是col1不为null且等于col1='true'的所有数据。我的完整语句如下:从

如何在SQL中实现以下功能。(我无法检查
col1
是否为空,检查
col2
是否为
“已确认”

从表1中选择数据,其中col1=“true”
或(如果
col1
为空,请选中
col2=“confirmed”


(检查
col1
col2
的值不同)

假设col2为非空。如果可以是
null
,则展开条件(与所示条件类似)


哎呀。。。我正在使用sqlite。谢谢你的回答。但是,我用sqlite尝试过,它不起作用。它只需要第一个条件。输出仅是col1不为null且等于col1='true'的所有数据。我的完整语句如下:从表1中选择名称、日期,其中(col1不为null且更低(col1)='true')或(col1is null且更低(col2)='confirm');我刚从SQL文档中发现。。。。。。。。。。。。“是”和“不是”操作符的工作方式类似于=和!=除非一个或两个操作数都为空。在这种情况下,如果两个操作数都为NULL,则IS运算符的计算结果为1(true),而IS NOT运算符的计算结果为0(false)。如果一个操作数为NULL,另一个为非NULL,则is运算符的计算结果为0(false),而is not运算符的计算结果为1(true)。is或is not表达式的计算结果不可能为NULL。运算符的优先级与=。任何其他选项!!
where (col1 is not null and col1='true')
or (col1 is null and col2='confirmed')