Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Review
Comparisons with NULL
Functions with NULL
COALESCE to the rescue
NULLIF
Review and practice
23. Summary

Instruction

Very nice. It's time to review what we've learned about NULLs so far:

  • Rule number one: Never trust a NULL. Keep your eyes open.
  • Use the operator IS NULL to check if the column is NULL.
  • Use the operator IS NOT NULL to check if the column is not NULL.
  • The equality and non-equality conditions (price = 7, price = NULL, price > 15) are never true when the argument is NULL.
  • Arithmetical operations (e.g. a + b) and most functions (e.g. a || b, length(a)) will return a NULL if any of the values is a NULL.
  • COALESCE(x, y, ...) returns the first non-NULL argument.
  • NULLIF(x, y) returns x when x != y or NULL when x = y.

Are you ready for a short quiz?

Exercise

Click Next exercise to get some practice!