I've got 2 tables: one stores tags, the other stores articles. There's a mode "Get articles by tag", which basically takes all articles, tagged "x". In my articles table I use a filed, called Tags
, that stores data in such pattern 'tag1, tag2, tag3, ...'.
So I want to get everything work by just a single query like that:
SELECT *,
(SELECT tagname
FROM `tags_table`
WHERE tagurn LIKE 'x') as TAGNAME
FROM `articles_table`
WHERE (Tags LIKE 'TAGNAME,%' OR Tags LIKE '%, TAGNAME' ... and so on)
I don't know if it's even possible, but I'd really like to use a single query (with a sub-query) instead of two different.