AnswerBun.com

How to merge same Ids data with mysql?

Stack Overflow Asked on January 3, 2022

I have records like this after applying joins

id   name   item
1    bil    Books
2    mike   Table
2    mike   chair
3    josh   pen
3    josh   pencil
4    peter  copy

But, I want them to look like this

id   name   item
1    bil    Books
2    mike   Table,chair
3    josh   pen, pencil
4    peter  copy 

How to achieve this?

One Answer

Use group by and group_concat():

select id, name, group_concat(item) items
from mytable
group by id, name

Answered by GMB on January 3, 2022

Add your own answers!

Related Questions

NiFi Consume kafka sasl_plaintext issue

1  Asked on February 13, 2021 by varun_rathinam

       

Clock divider in vhdl from 100MHz to 1Hz code

2  Asked on February 13, 2021 by mariaaaa

     

Inconsistent Paging in ASP.NET CORE

0  Asked on February 13, 2021 by addsw

       

Nuxt.js: can’t generate routes

3  Asked on February 12, 2021 by drake035

     

set year to the x labels in matplotlib

1  Asked on February 12, 2021 by nargento

     

Proper way to use Vuex with child components

1  Asked on February 12, 2021 by luma

     

is DRAM(main memory) a character device?

0  Asked on February 11, 2021 by jonggyu-park

   

How to declare a function that accepts a typed array parameter

1  Asked on February 11, 2021 by zentrunix

 

Loop nested array and return values by index

4  Asked on February 11, 2021 by jordan-starrk

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP