I have a table that associates records with corresponding tags with the following data:
entry_id | tag_id 1 | 1 2 | 1 3 | 1 1 | 2 2 | 2
I am trying to write a query that returns only tags with tags 1 and 2, in this example, records 1 and 2 will be returned, but 3 will not, because it does not have both tags. The current request that I use works, but I know that it cannot be right:
SELECT entry_id, GROUP_CONCAT(DISTINCT tag_id ORDER BY tag_id) FROM tags GROUP BY entry_id HAVING GROUP_CONCAT(DISTINCT tag_id ORDER BY tag_id) LIKE "%1,2%";
source share