
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 MySQL Returns When Passing NULL in CONCAT Function
As we know that CONCAT() function will return NULL if any of the argument of it is NULL. It means MySQL will return NULL if we pass column name, containing a NULL value, as one of the arguments of CONCAT() function. Following is an example of ‘Student’ table to explain it.
Example
In this example, we are concatenating the values of two strings and at 5th row one, the value is NULL hence the concatenation result is also NULL.
mysql> Select Name, Address, CONCAT(Name,' Resident of ',Address)AS 'Detail of Student' from Student; +---------+---------+---------------------------+ | Name | Address | Detail of Student | +---------+---------+---------------------------+ | Gaurav | Delhi | Gaurav Resident of Delhi | | Aarav | Mumbai | Aarav Resident of Mumbai | | Harshit | Delhi | Harshit Resident of Delhi | | Gaurav | Jaipur | Gaurav Resident of Jaipur | | Yashraj | NULL | NULL | +---------+---------+---------------------------+ 5 rows in set (0.00 sec)
Advertisements