📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

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 │ └────────────────────────────────┘

Was this page helpful?