我需要一些幫助。PHP數據如果數據不爲空
我想計算一些列,但我的查詢計數不正確。
SELECT COUNT(*) AS zero_count FROM messages WHERE uid_fk = '$uid' AND uploads IS NOT NULL AND uploads <>'' AND option = '1'
計數上傳值,如果上傳的值不爲空,並檢查選項=「1」
所以如果上傳值不爲空,並選擇= 1,那麼指望它。
例如:
uid_fk uploads option
1 75, 0 Not counting because secret_option is 0
1 76,77, 1 Count because it is 1 and upload value is not empty
1 1 Not count because upload value is empty
1 78, 1 Count because it is 1 and upload value is not empty
1 1 Not count because upload value is empty
1 79,80, 0 Not count because option is 0
我查詢計數所有選項= 1只,但它需要數:
如果上傳的值不爲空,並選擇是1,那麼指望它。
什麼我需要做的查詢計數上傳不空和選項= 1任何人都可以在這方面幫助我?
您是在計數行還是在上傳列中添加值? – Robert
@robert我想計數,如果上傳值不爲空,選項= 1。 – innovation
你需要什麼SUM或COUNT? –