group_concat

description

Syntax

VARCHAR group_concat(VARCHAR str[, VARCHAR sep])

This function is an aggregation function similar to sum (), and group_concat links multiple rows of results in the result set to a string. The second parameter, sep, is a connection symbol between strings, which can be omitted. This function usually needs to be used with group by statements.

example

  1. mysql> select value from test;
  2. +-------+
  3. | value |
  4. +-------+
  5. | a |
  6. | b |
  7. | c |
  8. +-------+
  9. mysql> select group_concat(value) from test;
  10. +-----------------------+
  11. | group_concat(`value`) |
  12. +-----------------------+
  13. | a, b, c |
  14. +-----------------------+
  15. mysql> select group_concat(value, " ") from test;
  16. +----------------------------+
  17. | group_concat(`value`, ' ') |
  18. +----------------------------+
  19. | a b c |
  20. +----------------------------+

keyword

GROUP_CONCAT,GROUP,CONCAT