将多个表达式添加在一起,并在它们之间添加 "-" 分隔符:
SELECT CONCAT_WS("-", "SQL", "Tutorial", "is", "fun!") AS ConcatenatedString;
亲自试一试 »
CONCAT_WS() 函数将两个或多个表达式与分隔符添加在一起。
笔记:另请参阅连接()功能。
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 |
工作于: | 从 MySQL 4.0 开始 |
---|
将三列(并在它们之间添加空格)添加到一个 "Address" 列中:
SELECT CONCAT_WS(" ", Address, PostalCode, City) AS Address
FROM Customers;
亲自试一试 »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!