Step by step mysql tutorials
CONCAT_WS() functions returns the concatenated string and adds a separator between each of the concatenated expressions. You may have one or more arguments.
It is a special form of CONCAT().
[table caption=”” width=”100%” colwidth=”15%|30%|55%” colalign=”left|left|left”]
Name, Required /Optional, Description
separator,Required, The separator to add between each of the expressions.
string1, Required, first parameter is must.
string2 , Required, second parameter is must.
stringN, Optional, N number of strings can be passed as parameter.
[/table]
[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Returns,
NULL,If the separator is NULL.
concatenated string, On the basis of inputs passed
[/table]
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 4.0
[/table]
mysql> SELECT CONCAT_WS('_','Tutorial', 'mines', '.net') ; +--------------------------------------------+ | CONCAT_WS('_','Tutorial', 'mines', '.net') | +--------------------------------------------+ | Tutorial_mines_.net | +--------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT CONCAT_WS('_','Tutorial', NULL, 'mines', '.net') ; // skips any NULL values +--------------------------------------------------+ | CONCAT_WS('_','Tutorial', NULL, 'mines', '.net') | +--------------------------------------------------+ | Tutorial_mines_.net | +--------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT CONCAT_WS('xxx','Tutorial', NULL, 'mines', '.net') ; +----------------------------------------------------+ | CONCAT_WS('xxx','Tutorial', NULL, 'mines', '.net') | +----------------------------------------------------+ | Tutorialxxxminesxxx.net | +----------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT CONCAT_WS('xxx','Tutorial', 'mines', '.net') ; +----------------------------------------------+ | CONCAT_WS('xxx','Tutorial', 'mines', '.net') | +----------------------------------------------+ | Tutorialxxxminesxxx.net | +----------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT CONCAT_WS(NULL ,'Tutorial', 'mines', '.net') ; +----------------------------------------------+ | CONCAT_WS(NULL ,'Tutorial', 'mines', '.net') | +----------------------------------------------+ | NULL | +----------------------------------------------+ 1 row in set (0.00 sec)
Below is the mysql terminal screen for above code :
See all MySQL String functions MySQL 8 String Functions.
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…