Back to JOINS, UNION, NULL HANDLING

NULL VALUES

Understand meaning of NULL values

3 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Introduction to NULLThe lesson introduces SQL null values as a potentially mysterious topic.
  2. Defining NULLA null value is defined as a field with no value, like an empty box or blank space.
  3. NULL vs Zero or SpaceIt is emphasized that NULL is distinct from zero or a space, representing 'I don't know what goes here'.
  4. How NULL is createdIf an optional field is skipped during insertion or update, SQL saves the value as null.
  5. Special Comparison NeededStandard comparison operators cannot be used to find null values, requiring special treatment.
  6. Using IS NULLThe IS NULL operator is used in the WHERE clause to find all records where a value is missing.
  7. Using IS NOT NULLThe IS NOT NULL operator is used to find records where the specified field contains a value.
  8. Summary and ReminderThe lesson concludes by reminding the learner to always use IS NULL and IS NOT NULL for handling missing data.
PDF notes

Frequently asked questions

Can I use `=` to check if a value is NOT NULL?

No. Standard comparison operators fail because NULL is not a value; it's a state. You must use IS NOT NULL.

If a field is optional, does it automatically become NULL if I skip it?

Yes, if the field is not defined as NOT NULL, SQL will save the record with a NULL value in that field.

Why does NULL need special operators?

NULL is treated as an unknown state, meaning it cannot logically equal or not equal any other value, including another NULL.