在做一个select查询,条件由用户输入,如果用户选择any,该怎么处理呢
例如:select * from tablename where [email protected] and [email protected],...
[email protected] "any ",[email protected]?
------解决方案--------------------
select * from tablename
where field1=isnull(@field1, field1) and field2=isnull(@field2, field2)
...
------解决方案--------------------
select * from tablename where ([email protected] or @field1 is null) and ([email protected] or @field is null)
对空值处理一下就好了
------解决方案--------------------
select * from tablename where ([email protected] or @field1 is null) and ([email protected] or @field2 is null)
对空值处理一下就好了
------解决方案--------------------
select * from tablename
where field1=isnull(@field1, field1) and field2=isnull(@field2, field2)