Skip to main content

IFNULL

If <expr1> is NULL, returns <expr2>, otherwise returns <expr1>.

Syntax

IFNULL(<expr1>, <expr2>)

Aliases

Examples

SELECT IFNULL(NULL, 'b'), IFNULL('a', 'b');

┌──────────────────────────────────────┐
│ ifnull(null, 'b') │ ifnull('a', 'b')
├───────────────────┼──────────────────┤
│ b │ a │
└──────────────────────────────────────┘

SELECT IFNULL(NULL, 2), IFNULL(1, 2);

┌────────────────────────────────┐
│ ifnull(null, 2) │ ifnull(1, 2)
├─────────────────┼──────────────┤
21
└────────────────────────────────┘
Did this page help you?
Yes
No
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today