Interview Question

What is IFNULL?

In MySQL, IFNULL(value, fallback) replaces a null value with one fallback.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

IFNULL is a MySQL function that returns its first argument when it is not NULL, otherwise its second argument. • It takes exactly two arguments. • Its result type follows MySQL type rules. • COALESCE is the standard-style alternative when more than two candidates are needed.

💡 SQL Example

SELECT IFNULL(nickname, full_name) AS display_name FROM customers;

Result

A non-null display name

⚡ Quick Revision

In MySQL, IFNULL(value, fallback) replaces a null value with one fallback.