SQLite ifnull() function
Description
The ifnull() function returns a copy of its first non-NULL argument, or NULL if both arguments are NULL.
Ifnull() must have exactly 2 arguments.
The ifnull() function is equivalent to coalesce() with two arguments.
Syntax:
ifnull(X,Y)
Example: SQLite ifnull() function
The following sqlite statement returns the first expression, i.e. 0, since the first expression is not NULL.
SELECT ifnull(0,2);
Sample Output:
ifnull(0,2) ----------- 0
Example: ifnull() function with non zero 1st argument
The following SQLITE statement returns the first expression, i.e. 1, since the first expression is not NULL.
SELECT IFNULL(1,2);
SELECT ifnull(1,2);
Sample Output:
ifnull(1,2) ----------- 1
Example: ifnull() function NULL
The following SQLITE statement returns the second expression, i.e. 2, since the first expression is NULL.
SELECT IFNULL(NULL,2);
SELECT ifnull(NULL,2);
Sample Output:
ifnull(NULL,2) -------------- 2
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook