【发布时间】:2017-10-28 04:52:55
【问题描述】:
我写的语法正确吗?
伪代码
select * from products
if @value is not null begin where category = @value end
+ if @value1 is not null begin where other1 = @value1 end
+ if @value2 is not null begin where other2 = @value2 end
+ if @value3 is not null begin where other3 = @value3 end
我是菜鸟。我不想写动态查询。上面的查询怎么写?
【问题讨论】:
-
这是错字吗?
ifs中的@value是否应该是@value1、@value2等?
标签: sql if-statement syntax where