我想獲得特定年份和特定月份以及特定用戶的所有桔子的總和。我嘗試了幾個選項,並且與&或。我不知道如何在超過3個條件下使用AND。下面是一個例子網格其例如期望的結果是2爲第一行
附例子在PIC格式和查詢我與嘗試之一是計算超過2個條件的行條目
查詢
SELECT count(*) FROM `usr_fruit`
where (d1="orange" or d2=" orange " or d3=" orange " or d4=" orange ")
and year=115 and usrNo= 1 and month=2
表看起來像這
usrNo d1 d2 d3 d4 month year
1 orange apple apple orange 2 115
1 apple apple apple apple 3 114
2 apple apple apple orange 2 115
2 apple apple apple apple 3 114
那麼究竟是什麼題?查詢失敗了嗎?返回錯誤的結果? – Mureinik
當我使用月= 2時,它只顯示1,但如果我刪除月= 1,那麼它給出結果爲2 .. – kpt
你有兩行橘子在其中。爲什麼這不正確? – Mureinik