- 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
While linking the strings, if I will add a NULL value then what would be the output of a CONCAT_WS() function?
Actually, CONCAT_WS() function returns NULL if and only if the first argument of it i.e. the separator is NULL. An example is as below −
mysql> Select CONCAT_ws(NULL,'Tutorial','Point','.com'); +-------------------------------------------+ | CONCAT_ws(NULL,'Tutorial','Point','.com') | +-------------------------------------------+ | NULL | +-------------------------------------------+ 1 row in set (0.00 sec)
Otherwise, MySQL CONCAT_WS() function ignores NULL if we place NULL at any other position in CONCAT_WS() function while linking the strings. Following examples will exhibit it −
mysql> Select CONCAT_ws('s','Tutorial','Point','.com',NULL); +-----------------------------------------------+ | CONCAT_ws('s','Tutorial','Point','.com',NULL) | +-----------------------------------------------+ | TutorialsPoints.com | +-----------------------------------------------+ 1 row in set (0.00 sec) mysql> Select CONCAT_ws('s','Tutorial',NULL,'Point','.com'); +-----------------------------------------------+ | CONCAT_ws('s','Tutorial',NULL,'Point','.com') | +-----------------------------------------------+ | TutorialsPoints.com | +-----------------------------------------------+ 1 row in set (0.00 sec)
Advertisements