I need to write a query that will return to me all the items in a group in one record, separated by commas,from two tables, example result below,
Items table:
--------------------
Name | Group_ID
--------------------
item1 | 1
item2 | 1
item3 | 3
Group table:
--------------------
ID | Name
--------------------
1 | Group1
3 | Group3
Result i'm looking for:
------------------------------
GId | Items
------------------------------
1 | item1, item2
3 | item3
USE GROUP_CONCAT
SELECT group_concat(Name) FROM table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With