简体   繁体   中英

Query for multiple values to an id separated with comma from the database

How to get result from database with multiple values to the same id separated by comma....

please help with this..

thank you

Id     |    Code
----------------------
0001   |   IN,ON,ME,OH
0002   |   ON,VI,AC,ZO
0003   |   QA,PS,OO,ME

Assuming you are using MySQL:

SELECT 
Id,
GROUP_CONCAT(Code SEPARATOR ',')
FROM
yourTable
GROUP BY Id

Here you can find further information .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM