SQL关于何处 /案例的问题
我在SQL Statment上有问题。 它具有选择参数值的选择框,包括“ A”,“ B”和空。 They will pass to :ABC value
How can I handle when select 'A', the data will show result related 'A', B will select B and empty will select both A and B.
I have no idea to handle when select "Empty ”,SQL将选择A和B。 非常感谢您帮助我。
Select * From table WHERE table.abc IN
(CASE WHEN :ABC = 'A' THEN 'A'
WHEN :ABC = 'B' THEN 'B'
WHEN :ABC IS NULL THEN ('A','B')
END);```
I have a problem on sql statment.
It has the selection box to choose parameter value, include 'A', 'B' and Empty. They will pass to :ABC value
How can I handle when select 'A', the data will show result related 'A', B will select B and empty will select both A and B.
I have no idea to handle when select "Empty", the sql will select both A and B.
Thank you so much for helping me.
Select * From table WHERE table.abc IN
(CASE WHEN :ABC = 'A' THEN 'A'
WHEN :ABC = 'B' THEN 'B'
WHEN :ABC IS NULL THEN ('A','B')
END);```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在Select ... 中使用
,代替(..)
可以解决此问题:Using
IN SELECT...
, in stead ofIN (..)
can solve this: