我有一个函数,它接受在where子句中使用的参数
function(string x) - >现在这将创建一个给出的sql查询
select colname from tablename where columnname=x;
Run Code Online (Sandbox Code Playgroud)
现在我希望这个函数给出所有行,即查询等价于
select colname from tablename;
Run Code Online (Sandbox Code Playgroud)
当我通过x ="全部"时.
我想创建一个通用查询,当我传递"全部"时,它应该返回我所有的行,否则过滤我的结果.
str*_*cer 10
只要离开那里的条件.
如果你真的想要那么复杂的使用
where columnname LIKE '%'
Run Code Online (Sandbox Code Playgroud)
这只会过滤空值.
select colname from tablename
where columnname=(case when @x ="All" then columnname
else @x end)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17153 次 |
最近记录: |