Skip to content

CONCAT_WS

CONCAT_WS(separator, string1, string2, …, stringN)

Section titled “CONCAT_WS(separator, string1, string2, …, stringN)”
  • separator: This is the string that will be used to join the other string arguments. If the separator is NULL, the result is NULL.
  • string1, string2, …, stringn: These are the strings that will be concatenated together. They are separated by the first separator argument. If any string value is NULL, then the CONCAT_WS() function treats it as an empty string (”).
SELECT CONCAT_WS(',', 'MySQL', 'MongoDB', 'PostgreSQL');
MySQL,MongoDB,PostgreSQL

The CONCAT_WS function in MySQL is used for concatenating multiple strings with a specified separator. In the given example, the strings ‘MySQL’, ‘MongoDB’, and ‘PostgreSQL’ are combined into a single string separated by commas. The result is “MySQL,MongoDB,PostgreSQL”.