SELECT table_categories.name, count(table_products.id) FROM table_categories LEFT JOIN products ON FIND_IN_SET(table_categories.id, products.cid) GROUP BY table_categories.name