本文介绍了案件何时何地何地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
declare @a int;
set @a=1;
select * from vehicles where company in (
case when @a=1 then (3,4) else (2)) end
此查询无法正常工作..任何人都可以帮助我
this query is not working.. Can anyone help me
推荐答案
declare @a int
declare @str varchar(30)
declare @query varchar(500)
set @a=1
set @str = '2'
if @a = 1
begin
set @str = '3,4'
end
set @query = 'select * from vehicles where company in (' + @str + ')'
exec (@query)
DECLARE @a INT;
SET @a=1;
SELECT * FROM vehicles
WHERE 1 =
(CASE
WHEN @a=1 AND company IN (3,4) THEN 1
WHEN @a=2 AND company=2 THEN 1
END)
快乐编码!
:)
Happy Coding!
:)
这篇关于案件何时何地何地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!