

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of MySQL CONCAT_WS() function?
Basically, MySQL CONCAT_WS() function is used to concatenate two or more strings along with a separator. Here the keyword WS in CONCAT_WS() means WITH SEPARATOR. We can pronounce CONCAT_WS() function as concatenation function with a separator.
Syntax
CONCAT_WS(Separator, String1,String2,…,StringN)
Here, the arguments of CONCAT_WS functions are Separator and the strings which need to be concatenated along with that separator as a single string. Separator except for numeric value must enclose within quotes.
Example
mysql> SELECT CONCAT_WS(' ','New', 'Delhi'); +-------------------------------+ | CONCAT_WS(' ','New', 'Delhi') | +-------------------------------+ | New Delhi | +-------------------------------+ 1 row in set (0.00 sec)
In this example above, we can see that the string ‘ ‘ (i.e. a white space) works as a separator and inserted between two strings, New and Delhi) which needs to be concatenated.
mysql> SELECT CONCAT_WS(' is our ','Delhi','Capital'); +-----------------------------------------+ | CONCAT_WS(' is our ','Delhi','Capital') | +-----------------------------------------+ | Delhi is our Capital | +-----------------------------------------+ 1 row in set (0.00 sec)
In this example above, we can see that the string ‘ is our ‘ works as a separator and inserted between two strings, Delhi and Capital, which needs to be concatenated.
- Related Questions & Answers
- What is the use of MySQL FROM_UNIXTIME() function?
- What is the use of MySQL GET_FORMAT() function?
- What is the use of MySQL LAST_INSERT_ID() function?
- What is the use of MySQL TRUNCATE() function?
- What is the use of MySQL UNHEX() function?
- What is the use of MySQL SUBSTRING_INDEX() function?
- What is the use of MySQL CHAR() function?
- What is the use of FIND_IN_SET () function in MySQL?
- What is the use of LOCATE() function in MySQL?
- What is the use of MySQL NULLIF() control flow function?
- What is the use of MySQL IFNULL() control flow function?
- What MySQL CONCAT() function returns by passing the numeric arguments?
- Use MySQL concat() and lower() effectively
- What is the use of JavaScript eval function?
- What happens if I pass only one argument to the MySQL CONCAT() function?