日期:2014-05-17  浏览次数:20691 次

case when 有么有返回语句的功能
select * from a where
(case when a.a1 is null then (select b.a1 from b) else a.a1 end )

case when能这样实现,但是这里会有个问题 如果 (select b.a1 from b) 返回多个值的时候,如何来解决呢

------解决方案--------------------
SQL code

select * from a
where exists (select 1 from b where a.a2 = (case when a.a1 is null then a1 else a.a1 end))