I have a table like this (created from joining different tables)

```
+------------+--------------+-------------+
| product_id | product_name | category_id |
+------------+--------------+-------------+
|     1      |    orange    |      3      |
|     1      |    orange    |      4      |
|     2      |    banana    |      2      |
|     3      |    apple     |      2      |
|     3      |    apple     |      3      |
|     3      |    apple     |      4      |
+------------+--------------+-------------+

```

I'd like it grouped together by ID, but sorted by name. 

Like this

```
+------------+--------------+-------------+
| product_id | product_name | category_id |
+------------+--------------+-------------+
|     3      |    apple     |      2      |
|     3      |    apple     |      3      |
|     3      |    apple     |      4      |
|     2      |    banana    |      2      |
|     1      |    orange    |      3      |
|     1      |    orange    |      4      |
+------------+--------------+-------------+

```

Is this possible? I tried using GROUP BY, but then it only keeps one row per product, so I can't see all the categories a product.

**edit: My query so far**

```
SELECT products.id as product_id, products.name as product_name, categories.id as category_id
FROM produkte
    LEFT JOIN prod_cat ON products.id = prod_cat.product_id
    JOIN categories ON prod_cat.category_id = categories.id
ORDER BY products.id

```

With "prod\_cat" being the table that assigns categories to products.