I have a table articles, another tags, and a third - article_tags. I want to create a page that lists all the articles for a specific tag.
My query looks like this:
SELECT headline, GROUP_CONCAT(tags.tag_name) AS all_tags FROM articles
LEFT JOIN articles_tags ON articles.article_id = articles_tags.article_id
LEFT JOIN tags ON articles_tags.tag_id = tags.tag_id
WHERE tags.tag_name = 'japan'
GROUP BY articles.article_id
All returned articles are japantagged, even if the article in question has multiple tags.
This is obviously related to the proposal WHERE, but I can't figure out how to do what I want here - ideally, I would get a list like japan,china,korea. Is this a place for a subquery? You can do with SQL gurus to advise.
Thanks Matt
source
share