~~~~~~~~~SQL语句关于Where中IN后用Case,马上给分!~~~~~~~ status in (case type_order when 'A' then 30,50 when 'B' then 20,30 end)status是int,这样写报错,应该如何写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from tb where type_order='a' and status in(30,50)union allselect * from tb where type_order='b' and status in(20,30) 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)+',%' where 1=1and (case type_order when 'A' then status in(30,50) when 'B' then status in(20,30) end) sql语句 求正确SQL语句 在SQL查询分析器中插入记录时,其余字段为默认值,如何做? 高手请进 用SQL如何得到数据库所对应的数据文件和日志文件并更改它们的名称 set @a=N'aaa'中的N是什么意思? 求助 急,急,急,求sql语句,马上给分 ttt 请教win98&win2000的数据安全问题? 能满意答复者给300分!(顺便要告诉我如何加分?) 合并连接查询问题 循环执行存储过程遇到一个奇怪的问题~!! 求sql
union all
select * from tb where type_order='b' and status in(20,30)
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)+',%'
where 1=1
and (case type_order when 'A' then status in(30,50) when 'B' then status in(20,30) end)