34,837
社区成员




where a.x=(case when @i_a is null then a.x else @i_a end)
and a.x=(case when @i_b is null then a.x else @i_b end)
可使用动态SQL,实现条件的筛选,优点:可重用执行计划,利用索引。select
from a join b on ....
where a.x=isnull(@i_a,a.x) and a.x= isnull(@i_b,a.x)
效率有木有问题,这个要看数据量、索引等等