juniorMySQL

Handling NULL values

Updated May 4, 2026

Short answer

Use IS NULL, IS NOT NULL, or the COALESCE() function.

Deep explanation

NULL represents an unknown value. Standard operators like '=' or '!=' do not work with NULL; specific keywords are required.

Real-world example

Checking if a user has not provided an optional phone number.

Common mistakes

  • Using 'WHERE column = NULL', which will always return an empty result.

Follow-up questions

  • What does COALESCE(val, 0) do?

More MySQL interview questions

View all →