0
I have the code SQL
SELECT SUM(r.quantity_domingo) AS quantity_domingo FROM reporters AS r INNER JOIN nucleos AS n ON r.id_nucleo = n.id INNER JOIN usuarios AS u ON n.id_user = u.id WHERE u.id_regiao = '1' AND MONTH(r.dia_domingo) = '11'
The problem is that in the table reports there is no record of phpmyadmin
when I execute the command, it returns to me quantity_domingo as NULL
. When I shoot SUM(r.quantity_domingo) AS quantity_domingo and replace by r.* he returns me "No Record" which would be right, because in PHP it keeps returning as if it had a line and I don’t want it.
Wouldn’t it just be a case of you evaluating the value returned? By the way, there is something that can cause confusion there, you are using a label with the same name of the column, wouldn’t it be better AS sum_quantidade_domingo ? Not that it will change the outcome, but only by habit.
– Bacco
Regardless of solving the problem, I think hitting JOINS would help, preferably by organizing everything with LEFT JOIN. Using INNER is best only when OUTER does not solve well: http://answall.com/questions/6441
– Bacco