首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

case when 有么有回到语句的功能

2012-11-05 
case when 有么有返回语句的功能select * from a where(case when a.a1 is null then (select b.a1 from b

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 awhere exists (select 1 from b where a.a2 = (case when a.a1 is null then a1 else a.a1 end)) 

热点排行