我想弄清楚如何在where子句中使用case語句(with!=),這裏是我想要做的事情的一個想法:CASE語句WHERE子句中!=條件
SELECT *
FROM Table1 JOIN Table2 JOIN Table3
WHERE
CASE @fruit
WHEN 'Apples' THEN (What would go here to return only data related to apples in Table1?)
WHEN 'Citrus' THEN (What would go here to return data related to either oranges or lemons in Table2?)
WHEN 'Other' THEN (return all data not related to apples, oranges, or lemons from all 3 tables) (!=)
END
我在where子句中看到了case語句的幾個例子,但沒有一個帶有!=的條件。有任何想法嗎?
你想實現什麼和SQL數據庫?如果你發佈你的數據和預期的輸出 – maSTAShuFu
SQL Server將會很有幫助。我試圖通過從SSRS傳遞一個變量來過濾表格 – user3088720
好吧......我可以說的是goodluck – maSTAShuFu