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
Post a Comment