0
我要寫正確的語法嗎?SQL Server - 什麼是正確的語法?
僞代碼
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」等嗎? – Mureinik