sql - display words from one ID in one line in mysql -


i have table so:

 id | word  ___________   1  | hello  1  | goodbye  1  | goodnight  2  |  2  | why  3  | yes  3  | no 

is there way collect words same id , display in 1 line so:

 id | word  _______________________________   1  | hello, goodbye, goodnight  2  | what, why  3  | yes, no 

use group_concat()

select id, group_concat(word separator ', ') word tablename group id 

output

╔════╦═══════════════════════════╗ ║ id ║           word            ║ ╠════╬═══════════════════════════╣ ║  1 ║ hello, goodbye, goodnight ║ ║  2 ║ what, why                 ║ ║  3 ║ yes, no                   ║ ╚════╩═══════════════════════════╝ 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -