आप MySQL GROUP_CONCAT ()
:
select i.id,
i.name,
group_concat(t.name SEPARATOR ', ') tags
from items i
left join items_to_tags it
on i.id = it.item_id
left join tags t
on it.tag_id = t.id
group by i.id, i.name
देखें SQL Fiddle with Demo
परिणाम:
| ID | NAME | TAGS |
---------------------------------
| 1 | item1 | tag1, tag2, tag3 |
| 2 | item2 | tag3 |