I want to search by tags, and then list all the articles with this tag, as well as the number of matching tags. So, for example, I could:
Page1 - 2 (has css and php tag)
Page2 - 1 (has only css tag)
Query:
SELECT COUNT(t.tag)
FROM a_tags t
JOIN w_articles2tag a2t ON a2t.tag = t.id
JOIN w_article a ON a.id = a2t.article
WHERE t.tag = 'css' OR t.tag = 'php'
GROUP BY t.tag
LIMIT 9
When I just set COUNT(t.tag), the query works, and I get good results. But if I add, for example, IDmy article, I get the following error:
ERROR: the column "a.title" should appear in the GROUP BY clause or be used in the LINE 1 aggregate function: SELECT COUNT (t.tag), a.title FROM a_tags t
How to add the specified columns to this query?
source
share