概要:函数LEFT JOIN与COUNT/GROUP BY的使用,以及为AND筛选限制条件的合适位置
SQL:
SELECT DISTINCT att.attributes_templates_id,att.attributes_templates_name,COUNT(p.products_id) FROM attributes_templates att
LEFT JOIN categories_to_templates ctt ON att.`attributes_templates_id` = ctt.`templates_id`
LEFT JOIN categories c ON ctt.