I have articles, which belong to article_types, which belong to categories. Each article has a format.
I want to list all articles published by a particular author, grouped by category.
I want to show all categories, even the ones with no articles.
All articles have an article_type and all categories contain article types.
I have a query that works perfectly on MySQL 5.5.x but not on 5.0. Is this a MySQL bug, or should the query be changed or both?
SELECT
a.article_id, a.article_time, a.article_notes f.format_name, at.article_type_name, c.category_name, c.category_description
FROM
article AS a
LEFT JOIN article_type AS at ON at.advice_id = a.advice_id
LEFT JOIN format AS f ON f.format_id = a.format_id
RIGHT JOIN category AS c ON c.category_id = at.cateory_id
WHERE
(a.author_id = 5 AND a.published = 1)
OR (a.author_id IS NULL)
ORDER BY
c.category_name ASC, a.article_time DESC
Desired Output (after simple php loop):
Category 1
Article A (Article Type I) (Digital)
Article B (Article Type I) (Print)
Article E (Article Type II) (Digital)
Category 2
Category 3
Article H (Article Type V) (Audio)
Article M (Article Type IV) (Print)