samedi 2 juillet 2016

Mysql counting same type and show the 0 [duplicate]

This question already has an answer here:

Hey guys i'm having a problem

SELECT tipo_util.nome as tipo,IFNULL(COUNT(utilizadores.id_tipo_util),0) as quant 
FROM utilizadores,tipo_util 
WHERE YEAR(data_inscri) = 2016 AND MONTH(data_inscri) = 1 and utilizadores.id_tipo_util=tipo_util.id 
GROUP BY tipo_util.nome

i'm using this select to get the name(as nome) and quantity of that type of name appear in the same month, but I need the zeros to transfer to a chart on jquery and is not working

this select give me this:

tipo      |  quant
Empresas  |      1

but I want to give me this:

Tipo    | quant
Empresas | 1
Padarias | 0
Supermercados | 0

like this

Aucun commentaire:

Enregistrer un commentaire