I want to display this as such
Category 1
Sub Category 1
Sub Category 2
Category 2
Sub Category 1
Sub Category 2
Sub Category 3
This is the query i have so far...
Code: Select all
SELECT a.name AS cat_name, a.category_id AS cat_id, b.sub_category_id AS sub_id, b.name AS sub_name
FROM `categories` a
LEFT JOIN sub_categories b ON a.category_id = b.category_id
GROUP BY cat_id, sub_id
ORDER BY cat_name ASC
LIMIT 0 , 30Does anyone know how I would do it so the category name only repeats once, regardless of the number of sub categories?