34,873
社区成员
发帖
与我相关
我的任务
分享select * from A where
email=case when isnull(@email,'0')='0' then email else @email end and
pname=case when isnull(@pname,'0')='0' then pname else @pname end and
tel=case when isnull(@tel,'0')='0' then tel else @tel end 最好加个NULL判断
begin
if @pname='0'
select * from A where tel=@tel and email =@email
else
begin
if @tel ='0'
select * from A where pname=@pnameand email =@email
else
begin
if @email='0'
select * from A where tel=@tel and pname=@pname
else
select * from A
end
end
endif (@pname='0')
select * from A where tel=@tel and email =@email
else if(@tel ='0')
....
else if(@email='0')
else if...
...select * from A where
email=case when @email='0' then email else @email end and
pname=case when @pname='0' then pname else @pname end and
tel=case when @tel='0' then tel else @tel end