these are the tables I have:
------ ---------- -------
|tags| -- |tagitems| -- |items|
------ ---------- -------
so tags have a m:n relationship with items.
I want to get a list of all tags with an additional boolean column which is created on the fly and holds for each tag the boolean value whether the tag has a relation to an item id I specify or not.
So the desired result is:
------------------------------
|tag.id | is_assigned_to_item|
------------------------------
| 1 | true |
| 3 | false |
------------------------------
What could be a query for this using mysql?
Cheers
Sebastian
Use an outer join to relate the tag table to the tagitems table, including the relevant item_id you specify in the ON clause.