concat_ws

Description

Syntax

VARCHAR concat_ws (VARCHAR sep, VARCHAR str,...) VARCHAR concat_ws(VARCHAR sep, ARRAY array)

Using the first parameter SEP as a connector, the second parameter and all subsequent parameters(or all string in an ARRAY) are spliced into a string. If the separator is NULL, return NULL. The concat_ws function does not skip empty strings, it skips NULL values.

example

  1. mysql> select concat_ws("or", "d", "is");
  2. +----------------------------+
  3. | concat_ws('or', 'd', 'is') |
  4. +----------------------------+
  5. | doris |
  6. +----------------------------+
  7. mysql> select concat_ws(NULL, "d", "is");
  8. +----------------------------+
  9. | concat_ws(NULL, 'd', 'is') |
  10. +----------------------------+
  11. | NULL |
  12. +----------------------------+
  13. mysql> select concat_ws("or", "d", NULL,"is");
  14. +---------------------------------+
  15. | concat_ws("or", "d", NULL,"is") |
  16. +---------------------------------+
  17. | doris |
  18. +---------------------------------+
  19. mysql> select concat_ws("or", ["d", "is"]);
  20. +-----------------------------------+
  21. | concat_ws('or', ARRAY('d', 'is')) |
  22. +-----------------------------------+
  23. | doris |
  24. +-----------------------------------+
  25. mysql> select concat_ws(NULL, ["d", "is"]);
  26. +-----------------------------------+
  27. | concat_ws(NULL, ARRAY('d', 'is')) |
  28. +-----------------------------------+
  29. | NULL |
  30. +-----------------------------------+
  31. mysql> select concat_ws("or", ["d", NULL,"is"]);
  32. +-----------------------------------------+
  33. | concat_ws('or', ARRAY('d', NULL, 'is')) |
  34. +-----------------------------------------+
  35. | doris |
  36. +-----------------------------------------+

keywords

  1. CONCAT_WS,CONCAT,WS,ARRAY