status in (case type_order when 'A' then 30,50 when 'B' then 20,30 end)
status是int,这样写报错,应该如何写?
分享到:
------解决方案-------------------- case返回的是一个确定的标量值,30,50这显然不是一个值
select * from tb where (type_order='a' and status in(30,50)) or
(type_order='b' and status in(20,30) ) ------解决方案--------------------
把语句改一下,试试:
and
(case type_order when 'A' then ',30,50,'
when 'B' then ',20,30,'
end) like '%,'+cast(status as varchar)+',%'