I have 2 tables in a database. I use following query:
Select U.id, U.ad, COUNT(B.id) AS 'total'
FROM tblProducts U
INNER JOIN TblBasvurular B ON B.urunid=U.id
GROUP BY u.id,u.ad
this show me
id | productname | total
-------------------------------
1 | bread | 2
2 | water | 3
3 | milk | 1
but I can’t see other products. If does not exist it does not show me others.
How can I get result like this:
id | productname | total
-------------------------------
1 | egg | 0
2 | bread | 2
3 | water | 3
4 | tea | 0
5 | milk | 1
It is not clear enough, because you didn’t show us second table.
But try to change inner join to left join in your query: