I have Post HABTM Tags
(tables: posts
, tags
, posts_tags
).
When I delete Post also deleting relations from post_tags
table - it's okey, but in table tags
there are still not used tags.
How resolved remove not uset tags?
I have Post HABTM Tags
(tables: posts
, tags
, posts_tags
).
When I delete Post also deleting relations from post_tags
table - it's okey, but in table tags
there are still not used tags.
How resolved remove not uset tags?
Okey, I found the simplest way: https://stackoverflow.com/a/1451323/182823:
DELETE FROM tags WHERE not exists (SELECT * FROM tags_places WHERE tags_places.tag_id = tags.id)