I have an items Table and a Tags table. Now what I would like is to have one Select that gets Items under a certain condition and for each item selects the related tags and puts them in a string to become a seperate field.
Example:
table_items:
id | title
---------------------------
01 | peter
---------------------------
02 | john
---------------------------
03 | cindy
tags:
id | title
---------------------------
01 | tall
---------------------------
02 | tiny
---------------------------
03 | blone
---------------------------
04 | loud
---------------------------
05 | ...
tags_to_items:
itemid | tagid
---------------------------
01 | 02
---------------------------
01 | 04
---------------------------
02 | 01
...
I think you get the point.
Now I want a result like this:
itemid | title | tags
---------------------------
01 | peter | tiny, loud
---------------------------
01 | john | tall, fast, bored
Can I do this with just MySQL?
How?
In MySQL, you need
GROUP_CONCATfunction to do that.Something like: