I want to join multiple row values from table.
Table name:Item
    ID |            item_id |     Value
    1               43          item1
    2               44          item2
    3               44          item3
    4               44          item4
    5               45          item5
    6               45          item6
ID's are unique (primary key) What I am looking to output is a mysql query is something to which gives this output as given below
Output:
  ID |            item_id |     Value
    1               43          item1
    2               44          item2,item3,item4
    3               44          item2,item3,item4
    4               44          item2,item3,item4
    5               45          item5,item6
    6               45          item5,item6
kindly requesting to give some suggestions
Try this query:
SELECT t1.ID, t1.item_id, t2.Value
FROM item t1
INNER JOIN
(
    SELECT item_id, GROUP_CONCAT(Value) AS Value
    FROM item
    GROUP BY item_id
) t2
    ON t1.item_id = t2.item_id
Follow the link below for a running demo:
SQLFiddle
You can use below query.
SELECT GROUP_CONCAT(value) FROM Item GROUP BY item_id;
                        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