How can I select the tag accurately from the tag column with the list of tag?
For instance below is table created using a query, but then I want to narrow down my search,
page_id tags
1 tile-1,tile-12,tile-10
2 tile-1,tile-10
3 tile-12,tile-10
4 tile-15,tile-16
the result I am after is the pages with tile-1 only,
page_id tags
1 tile-1,tile-12,tile-10
2 tile-1,tile-10
But the query I am working on below returns all of them, including, tile-12, tile-10, etc.
SELECT*
FROM (...) AS k
WHERE k.tags LIKE '%tile-1%'
May I should not use LIKE?
I suggest to change schema to page_id, tag. so that your data should look like this
Then you can do all this with a simple query,
This way you do not have to search through the table (table scans) – which will become an issue once table has more rows (scalable solution).
Second you can use index on the tag column, to make searches super fast.