如果参数 num = 1 或者 2 就查询 select * from table where num = 1 or num = 2
其他情况就查询 select * from table where num = num如果不用动态sql怎么做?sql语句太长了,用动态sql后面看起来很麻烦
其他情况就查询 select * from table where num = num如果不用动态sql怎么做?sql语句太长了,用动态sql后面看起来很麻烦
DECLARE @num INT
IF @num=1
select * FROM table where num = 1 or num = 2
ELSE
select * FROM table where num = @num
IF @num=1 or @num=2
select * FROM table where num = 1 or num = 2
ELSE
select * FROM table where num = @num
DECLARE @num INT
IF @num=1 or @num=2
select * FROM table where num = 1 or num = 2
ELSE
select * FROM table where num = @num
if num =1 or num =2
set num = '1,2'select * FROM table where num in num
要么动态sql
其他没有办法了