
- 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
How can we distinguish between MySQL IFNULL() and NULLIF() functions?
Actually, both MySQL IFNULL() and NULLIF() functions are having an almost same syntax as given below −
The syntax of IFNULL()
IFNULL(expression1, expression2)
The syntax of NULLIF()
NULLIF(expression1, expression2)
They can be distinguished in the way they return the first argument as result. IFNULL() function will return the first argument as a result if it is not NULL and NULLIF() function will return the first argument as a result if both the arguments are not same.
mysql> Select IFNULL('Ram','Shyam'); +-----------------------+ | IFNULL('Ram','Shyam') | +-----------------------+ | Ram | +-----------------------+ 1 row in set (0.00 sec) mysql> Select NULLIF('Ram','Shyam'); +-----------------------+ | NULLIF('Ram','Shyam') | +-----------------------+ | Ram | +-----------------------+ 1 row in set (0.00 sec)
From the above result set of both the functions, it looks like they are similar but IFNULL() function returns ‘Ram’ because of it the first argument of it and it is not NULL. On the other hand NULLIF() function returns ‘Ram’ because it is the first argument and it is different from the second argument.
- Related Questions & Answers
- How can we distinguish between MySQL CROSS JOIN and INNER JOIN?
- Can we use IFNULL along with MySQL ORDER BY?
- How can we combine functions in MySQL?
- Can we distinguish numbers as lucky and unlucky numbers?
- What are MySQL stored functions and how can we create them?
- Distinguish between entrepreneurship and management.
- Distinguish between profitability and liquidity.
- Distinguish between GST and SST
- How can we calculate the Date in MySQL using functions?
- How can we transfer information between MySQL and data files?
- Distinguish between EBIT and net income.
- Distinguish between active and passive investment.
- Distinguish between the TCP and UDP.
- Distinguish between contingent liabilities and provisions
- How can we use the output of LTRIM() and RTRIM() functions to update MySQL table?
Advertisements