1
select `temp`, IfNULL(count(id),0) t
from survey
where `temp`<>'NULL' and `temp`<> '' and date(submitdate)='date'
group by `temp
與O/P查詢
temp t
A1 1
但這裏是在選定的日期會發生什麼,如果沒有記錄:我沒有得到任何結果。答案是像A1,A2,A3
我需要這樣的
temp t
A1 1
A2 0
A3 0
你必須有一個不同的表,它具有所有類型的'臨時',像A1,A2 .. 我的意思是 哪張表是你想要得到A1,A2,A3 –
你正在比較字符串'NULL'而不是記錄列爲NULL的地方 - 這是故意的嗎? – Bridge