MariaDB: CONCAT_WS Function
This MariaDB tutorial explains how to use the MariaDB CONCAT_WS function with syntax and examples.
Description
The MariaDB CONCAT_WS function allows you to concatenate two or more expressions together and adds a separator between each of the concatenated expressions.
Syntax
The syntax for the CONCAT_WS function in MariaDB is:
CONCAT_WS( separator, expression1, expression2, ... expression_n )
Parameters or Arguments
- separator
- The separator that is added between each of the concatenated expressions.
- expression1, expression2, ... expression_n
- The expressions to concatenate together.
Note
- The CONCAT_WS function skips expressions (ie: expression1, expression2, ... expression_n) that contain a NULL value.
- If separator is a NULL, the CONCAT_WS function will return a NULL value.
- See also the CONCAT function.
Applies To
The CONCAT_WS function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB CONCAT_WS function examples and explore how to use the CONCAT_WS function in MariaDB.
For example:
SELECT CONCAT_WS('_', 'Tech', 'On', 'The', 'Net'); Result: 'Tech_On_The_Net' SELECT CONCAT_WS(',', 1, 2, 3, 4); Result: '1,2,3,4' SELECT CONCAT_WS(', ', 1, 2, 3, 4); Result: '1, 2, 3, 4' SELECT CONCAT_WS('ABC', 'x', 'y', 'z'); Result: 'xABCyABCz' SELECT CONCAT_WS('ABC', 'x', 'y', NULL, 'z'); Result: 'xABCyABCz' SELECT CONCAT_WS(NULL, 'x', 'y', 'z'); Result: NULL
Advertisements