Hvis du vil have indlæg uden kommentarer:
SELECT
post.post_id,
--post.title,
--post.content,
COUNT(comment.post_id) AS comment_count
FROM post
LEFT JOIN comment ON post.post_id = comment.post_id
GROUP BY post.post_id
ORDER BY comment_count DESC
(Denne forespørgsel bruger MySQL'erne GROUP BY with with skjulte kolonner udvidelse).
Hvis du ikke vil have indlæg uden kommentarer, kan du bruge en enklere forespørgsel:
SELECT post_id, COUNT(*) AS comment_count
FROM comment
GROUP BY post_id
ORDER BY comment_count DESC