bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL CONCAT_WS() Function

Concept visual

MySQL CONCAT_WS() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Add several expressions together, and add a "-" separator between them:

SELECT CONCAT_WS("-", "SQL", "Tutorial", "is", "fun!") AS ConcatenatedString;

Definition and Usage

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

Note:

Also look at the CONCAT() function.

Syntax

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

Parameter Values

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

Technical Details

Works in:

From MySQL 4.0

More Examples

Example

Add three columns (and add a space between them) into one "Address" column:

SELECT CONCAT_WS(" ", Address, PostalCode, City) AS Address

From

Customers;

Previous

❮ MySQL Functions

Next

Previous

MySQL CONCAT() Function

Next

MySQL FIELD() Function