为了账号安全,请及时绑定邮箱和手机立即绑定

sql语句怎么实现动态条件

sql语句怎么实现动态条件

慕的地10843 2018-11-10 14:20:13
select * from T where operator = (case when @type = 0 then @o1 else is not null end) 主要是想根据@type 用不同的条件当@type = 0 时 operator = @o 否则 operator is not null 请问各位大侠SQL语句怎么写,最好不要用字符串拼接
查看完整描述

2 回答

?
阿波罗的战车

TA贡献1862条经验 获得超6个赞

select *

 from T 

where (operator = @o1 and @type = 0 ) or ( @type <> 0 and operator is not null )

查看完整回答
反对 回复 2018-11-14
  • 2 回答
  • 0 关注
  • 625 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信