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
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework