我有一个这样的示例查询:
select t1.name,t1.bday,t2.address,t2.contactnum
from table1 as t1
left join table2 as t2 on t1.p_id = t2.p_id
where (case when @qualified = '2' then t2.role is null
case when @qualified = '3' then t2.role is not null` end)
当我执行查询时,会弹出一个错误提示:
关键字“is”附近语法不正确。
这位各位有什么解决办法吗?
谢谢!
此查询目的在于获取表中的空行和非空行,具体取决于参数@qualified所传递的值。
case when
是为了实现什么目的?你在查询中错误地放置了is null
和is not null
。 - Mohammad DehghanCASE
只能返回一个单一的、原子的值 - 而不是表达式或代码块。 - marc_s