如果变量为空,则 No Where 子句 [英] If Variable is Blank Then No Where Clause
本文介绍了如果变量为空,则 No Where 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试执行以下伪代码推断的操作:
I am trying to do what the below pseuedo code infers:
WHERE
CASE
WHEN @test <> '' THEN Agent = @test
ELSE --no where clause
END
正确的结构是什么?
推荐答案
use OR:
select * from yourTable
where @test = '' OR Agent = @test
如果@test
带有空值(而不是 ''
),则必须使用:
if @test
coming with null value (instead of ''
), you must use:
select * from yourTable
where @test is null OR Agent = @test
这篇关于如果变量为空,则 No Where 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文