- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In MySQL, how can I combine two or more strings along with a separator?
In MySQL, we can combine two or more strings along with a separator by using CONCAT_WS() function. The syntax of this function is 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('.','www','tutorialspoint','com'); +---------------------------------------------+ | CONCAT_WS('.','www','tutorialspoint','com') | +---------------------------------------------+ | www.tutorialspoint.com | +---------------------------------------------+ 1 row in set (0.00 sec)
In this example above, we can see that the separator ‘.‘ (i.e. a dot) inserted between three strings, www, tutorialspoint and com) which needs to be concatenated.
Advertisements