CONCAT_WS() – Add two or more expressions together with a separator in MySQL

Spread the love

CONCAT_WS() –

The CONCAT_WS() function adds two or more expressions together with a separator.

Syntax –

CONCAT_WS(separator, expression1, expression2, expression3,...)

separator – The separator to add between each expressions.

expressions – The expressions to add together.

Example –

SELECT CONCAT_WS("-", "I", "am", "learning","SQL") AS ConcatenatedString;
SELECT CONCAT_WS(" ", ENAME, "works as", JOB) AS emp_info
FROM emp;

Rating: 1 out of 5.

Leave a Reply