Today I learn a new function in SQL. CONCAT_WS and CONCAT function returns a string resulting from the concatenation or joining, of two or more string values in an end-to-end manner. But CONCAT_WS separates those concatenated string values with the delimiter specified in the first function argument. CONCAT_WS requires a separator argument and a minimum of two other string value arguments; otherwise, CONCAT_WS will raise an error.
If CONCAT_WS receives arguments with all NULL values, it will return an empty string of type varchar(1).
Syntax
CONCAT_WS(separator, string1, string2, ...., string_n)
Example.
SELECT CONCAT_WS('+', 'It', 'add', 'with','plus sign.');
Result:
It+add+with+plus sign.
For
SELECT CONCAT('It',' only', ' concat',' string.');
Result:
It only concat string.
You can get more details about it by following the link.
Top comments (0)