In the below query I am trying to order the results by fc.order
in ascending order:
SELECT *, count(*) AS threads_count FROM (
SELECT fc.uuid AS category_uuid, fc.name, fc.description, fc.order, fc.icon,
u.uuid AS user_uuid, u.username, u.avatar
FROM forum_categories AS fc
INNER JOIN forum_threads AS ft ON fc.id = ft.forum_category_id
INNER JOIN users as u ON ft.created_by = u.id
ORDER BY fc.order ASC, ft.created_at DESC
) AS tmp_table GROUP BY category_uuid
However it doesn't seem to be working. Below is a screenshot of results from the above query:
How can I get the results to order by the order
column?
ok thanks guys but I got it:
SELECT * FROM (
SELECT *, count(*) AS threads_count FROM (
SELECT fc.uuid AS category_uuid, fc.name, fc.description, fc.order, fc.icon,
u.uuid AS user_uuid, u.username, u.avatar
FROM forum_categories AS fc
INNER JOIN forum_threads AS ft ON fc.id = ft.forum_category_id
INNER JOIN users as u ON ft.created_by = u.id
ORDER BY ft.created_at DESC
) AS t1 GROUP BY category_uuid
) as t2 ORDER BY `order`