let's assume we have three table which can be used for simple website with Tags.
fist table "videogame"
id | title | reg_date | Content |
---|---|---|---|
1 | BioShock Infinite | 2016-08-08 | .... |
"tags" table
id | name |
---|---|
1 | yennefer |
2 | elizabeth |
"tags_meta" table
post_id | tag_id |
---|---|
1 | 2 |
SELECT videogame.id,
videogame.title,
videogame.reg_date,
tags.name,
tags_meta.post_id
FROM tags_meta
INNER JOIN videogame ON videogame.id = tags_meta.post_id
INNER JOIN tags ON tags.id = tags_meta.tag_id
WHERE tags.name = "elizabeth"
ORDER BY videogame.reg_date
this code can return all posts which related to that tag "#elizabeth"