Add several expressions together, and add a "-" separator between them:
SELECT CONCAT_WS("-", "SQL", "Tutorial", "is", "fun!") AS ConcatenatedString;
Try it Yourself »
The CONCAT_WS() function adds two or more expressions together with a separator.
Note: Also look at the CONCAT() function.
CONCAT_WS(
separator,
expression1,
expression2,
expression3,...)
Parameter | Description |
---|---|
separator | Required. The separator to add between each of the expressions. If separator is NULL, this function returns NULL |
expression1, expression2, expression3, etc. |
Required. The expressions to add together. An expression with a NULL value will be skipped |
Works in: | From MySQL 4.0 |
---|
Add three columns (and add a space between them) into one "Address" column:
SELECT CONCAT_WS(" ", Address, PostalCode, City) AS Address
FROM Customers;
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!