Reputation: 585
How can I check if a tag is at least used once based on the structure below.
Upvotes: 0
Views: 50
Reputation: 657397
An EXISTS
semi-join is most probably the fastest of several possible query styles for this task:
SELECT t.*
FROM taggit_tag t
WHERE EXISTS (
SELECT 1
FROM taggit_taggeditem ti
WHERE ti.tag_id = t.tag_id
);
Upvotes: 3