我需要在一个表中查询空值,但在不同的字段上。我一直在独立设置查询,并一次运行一个查询以查看结果。
EX:
查询1:
select * from TABLE1 where FIELD1 is null and FIELD2 is NOT null
查询2:
Select * from TABLE1 where FIELD6 = 'YES' and FIELD2 is null
查询3:
select * from TABLE1 where FIELD4 = 'OUTSIDE' and FIELD7 is not null
是否可以设置一个查询,使我可以从单个表中检索数据,但可以在条件不同的情况下运行查询?
答案 0 :(得分:2)
您似乎可以使用or
运算符:
select * from TABLE1
where (FIELD1 is null and FIELD2 is NOT null)
or (FIELD6 = 'YES' and FIELD2 is null)
or (FIELD4 = 'OUTSIDE' and FIELD7 is not null)