I have a tag list. I want to list all tags and the total count each tag is used.
I can get the result using a LEFT JOIN. My problem is that my statement does not include tags that are not used. If possible, I also wanted to show all tags (used and not used in one SQL statement).
SQL Statement:
SELECT tag.name, COUNT(tag.id)
FROM tags
LEFT JOIN posts ON posts.tagid = tags.id
WHERE posts.published = 'yes'
GROUP BY posts.tagid