
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
Use of MySQL IFNULL Control Flow Function
MySQL IFNULL() control flow function will return the first argument if it is not NULL otherwise it returns the second argument.
Syntax
IFNULL(expression1, expression2)
Here if expression1 is not NULL then IFNULL() will return expression1 otherwise expression2. It will return NULL if both of the arguments are NULL. Following example will exhibit this −
mysql> Select IFNULL(NULL,'Ram'); +--------------------+ | IFNULL(NULL,'Ram') | +--------------------+ | Ram | +--------------------+ 1 row in set (0.00 sec) mysql> Select IFNULL('Shyam','Ram'); +-----------------------+ | IFNULL('Shyam','Ram') | +-----------------------+ | Shyam | +-----------------------+ 1 row in set (0.00 sec) mysql> Select IFNULL(NULL,NULL); +-------------------+ | IFNULL(NULL,NULL) | +-------------------+ | NULL | +-------------------+ 1 row in set (0.00 sec)
Advertisements