用SQL检测俩字段是否同时为空或同时不为空

常规写法:

select * from temp

where 字段1 is null and 字段2 is not null or 字段1 is not null and 字段2 is null

高级写法:

select * from temp

where decode(字段1,null,0,1) + decode(字段2,null,0,1) = 1

 

以上执行结果,为一个字段为空,另一个字段不为空的数据

posted @ 2021-08-27 17:07  网瘾少女  阅读(2225)  评论(0)    收藏  举报