There are 3 tables:
"goods" - goods.
"grup_goods" - stores information about groups of goods.
"grup_link_goods" - links the goods table with the grup_goods table.
The task is to deduce the categories and quantity of the goods in them, I do this:
SELECT gr_g.url AS url, gr_g.grup_img AS grup_img, gr_g.name_menu AS name_menu, gr_g.title AS title, IFNULL(COUNT(gr_l_g.id), 0) AS count FROM grup_goods AS gr_g LEFT JOIN grup_link_goods AS gr_l_g ON (gr_g.id = gr_l_g.id_grup) WHERE gr_g.id_part=.$id. GROUP BY gr_l_g.id_grup ORDER BY gr_g.id ASC
All would be nothing)), but the result is a little not what was expected: It turns out something like this:
name_menu | count (5 ัั) name_menu | count (3 ัั) name_menu | count (0 ัั)
And you need:
name_menu | count (5 ัั) name_menu | count (3 ัั) name_menu | count (0 ัั) name_menu | count (0 ัั) name_menu | count (0 ัั)
Only one category with the quantity of goods = 0 is displayed, and the rest with a zero quantity disappears somewhere ((.
What could be the problem???