我的查询如下
select --------
from table a
left outer join ....c
where
(a.column='123') and (c.column='456')
我想
包括“(c.column ='456')”仅当(c.column ='456')不为空时
如何在单个查询中执行此操作?或者我需要写两个单独的查询?
我试过(a.column ='123')和(c.column为空),没有用
答案 0 :(得分:3)
尝试:
select --------
from table a
left outer join ....c
where
((a.column='123') and (c.column='456'))
or c.column is not NULL
答案 1 :(得分:0)
尝试将检查为null,将值456放在同一组括号中:
select --------
from table a
left outer join ....c
where
(a.column='123') and (c.column is not null and c.column='456')