SELECT * FROM Table where a.TenantKey=@TenantId AND (@ProjectKeys is null or b.RecuritProjectKey in (select * from dbo.f_SplitToInt(@ProjectKeys,‘,‘))) AND (@ProjectDutyUserKeys is null or b.ProjectDutyUserKey in (select * from dbo.f_SplitToInt(@ProjectDutyUserKeys,‘,‘)))
当@ProjectKeys&@ProjectDutyUserKeys两个参数有值无值都不会影响查询,省去了IF……ELSE……
where语句中多条件查询字段NULL与NOT NULL不确定性查询,布布扣,bubuko.com
where语句中多条件查询字段NULL与NOT NULL不确定性查询
原文地址:http://www.cnblogs.com/huyg/p/3853678.html