我想合併我的2 If語句的條件結果。首先,如果語句結果只顯示0結果,則在第二個語句結果中,其中一個必須大於0 ...我想要做的是保留第二個條件,如果狀態像我的代碼那樣首先修改...如何在WHERE子句中使用IF ... ELSE條件?
If (Inventory) <> 0 Then
If Apple = "" And Banana = "" Then
strSQL = strSQL & " AND (myApple = 0 AND myBanana = 0)"
End If
End If
If int(Inventory) <> -1 Then
If Apple = "" And Banana = "" Then
strSQL = strSQL & " AND (myApple <> 0 OR myBanana <> 0)"
End If
End If
這裏是在什麼我兩個條件導致小表:我想
Inventory | Desired result
-----------+---------------
-1 | show both zero or at least one not be zero (Show all)
0 | at least one must not be zero |
['CASE'](http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/case_statement.htm)statement – canon
So您有條件地創建基於庫存,蘋果和香蕉價值的SQL語句。你是否試圖將整個語句移入SQL?目前還不清楚你想要做什麼。 – Joe
所以你有條件地創建一個基於庫存,蘋果和香蕉值的SQL語句:是的 – user2611251