I have the following SQL statement
SELECT
x_category.id,
x_category.name,
x_category.parent
FROM x_listings, x_category
WHERE x_listings.status = 1
AND
(x_listings.cat_1_id = x_category.id OR
x_listings.cat_2_id = x_category.id OR
x_listings.cat_3_id = x_category.id)
GROUP BY x_category.id
ORDER BY x_category.id, x_category.parent
This returns:
id, name, parent
1, Toys, 0
2, Clothes, 0
3, Hardware, 0
4, Educational Toys, 1
5, Women's Clothes, 2
6, Men's Clothes, 2
7, Hammers, 3
However, I want the results to come back ordered as such:
id, name, parent
1, Toys, 0
4, Educational Toys, 1
2, Clothes, 0
5, Women's Clothes, 2
6, Men's Clothes, 2
3, Hardware, 0
7, Hammers, 3
How can I modify the SQL statement to achieve this?
Thanks