这个应如何修改?在线等。
select * from a where case when @id is null then 1=1 else id=@id end
这个SQL出错啦。
当WHERE 后面有多个条件时的应如何?
问题点数:0、回复次数:4Top
1 楼aw511(点点星灯)回复于 2005-06-02 12:33:48 得分 0
case不可以那样用,你要表达什么意思呢?Top
2 楼libin_ftsafe(子陌红尘:TS for Banking Card)回复于 2005-06-02 12:38:20 得分 0
select * from a where id = isnull(@id,id)Top
3 楼47522341(睡到8:30)回复于 2005-06-02 13:31:20 得分 0
1、select * from a where @id is null or id = @ID
2、select * from a where isnull(@id,id) = idTop
4 楼Hopewell_Go(好的在后頭﹗希望更好﹗﹗)回复于 2005-06-02 19:59:43 得分 0
select *
from a
where
(id=@id or @id is null)
Top




