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. +----------------------------+
8. mysql> select concat_ws(NULL, "d", "is");
9. +----------------------------+
10. | concat_ws(NULL, 'd', 'is') |
11. +----------------------------+
12. | NULL |
13. +----------------------------+
15. mysql> select concat_ws("or", "d", NULL,"is");
16. +---------------------------------+
17. | concat_ws("or", "d", NULL,"is") |
18. +---------------------------------+
19. | doris |
20. +---------------------------------+
22. mysql> select concat_ws("or", ["d", "is"]);
23. +-----------------------------------+
24. | concat_ws('or', ARRAY('d', 'is')) |
25. +-----------------------------------+
26. | doris |
27. +-----------------------------------+
29. mysql> select concat_ws(NULL, ["d", "is"]);
30. +-----------------------------------+
31. | concat_ws(NULL, ARRAY('d', 'is')) |
32. +-----------------------------------+
33. | NULL |
34. +-----------------------------------+
36. mysql> select concat_ws("or", ["d", NULL,"is"]);
37. +-----------------------------------------+
38. | concat_ws('or', ARRAY('d', NULL, 'is')) |
39. +-----------------------------------------+
40. | doris |
41. +-----------------------------------------+
keywords
1. CONCAT_WS,CONCAT,WS,ARRAY
