sql 参数组合条件查询,条件为空不考虑如:select a,b,c from t0
inner join (
select
t1.Model
from t1
where 条件
) t80 on t80.Model=t0.Modelwhere 条件 现在是想传入参数, @a ,@b ,@c 当他们不为空时才作为条件。
比如:如果@a='' 那么 就不用把a=@a考虑进来。这时 where b=@b,c=@c;
inner join (
select
t1.Model
from t1
where 条件
) t80 on t80.Model=t0.Modelwhere 条件 现在是想传入参数, @a ,@b ,@c 当他们不为空时才作为条件。
比如:如果@a='' 那么 就不用把a=@a考虑进来。这时 where b=@b,c=@c;
a=case when isnull(@a,'')='' then a else @a end
这句话是什么意思
我想传一个参数@sql select a, b,c frm tb where @sql当然,如果直接执行这句话好像是有语法错误的。
那应该怎么处理好
select @tsql='select a, b,c from tb where '+@sql -->@sql是传入参数
exec(@tsql)