SQLMarrow / Course Academy Experience

SQL & Databases Masterclass Course

Welcome to the ultimate postgresql tutorial for beginners 2026. Work through interactive sql practice problems with solutions, master our comprehensive sql window functions tutorial modules, and prepare for tough sql interview questions at Google and Amazon entirely in your browser. Claim your course completion XP and build production-ready database mastery today!

COURSE PROGRESS
0%
0 of 40 Modules Solved
COURSE SYLLABUS
40 Lessons
LESSON WORKSPACEBeginner

SQL Lesson 8: A short note on NULLs

Introduction & Core Concept

In relational databases, NULL represents a state of missing, unknown, unassigned, or undefined data.

It is crucial to understand that NULL is not equivalent to zero (0), nor is it equivalent to an empty text string (''). Zero is a specific number, and an empty string is a valid text value. NULL means the value is completely absent.

Because NULL represents an unknown state, standard mathematical comparison operators (like = NULL or != NULL) always evaluate to unknown and fail to return rows. Instead, you must use specialized null-checking operators:

  • IS NULL: Evaluates to true if the attribute is empty/missing.
  • IS NOT NULL: Evaluates to true if the attribute contains populated data.
  • Why & Where We Use It
  • Why We Use It: Allows systems to distinguish between a customer who has a balance of $0.00 versus a customer whose balance has not yet been calculated.
  • Where We Use It: Filtering out optional form inputs, finding unassigned support tickets, and identifying broken relational links after LEFT JOIN operations.
  • Real-World Example

    Suppose you run a LEFT JOIN connecting registered SpotifyLite artists to their uploaded songs. To isolate specifically the artists who have *never* uploaded a song, you filter the results using WHERE s.id IS NULL.

    Best Practices: What to Do & What NOT to Do
  • What to Do: Use defensive functions like COALESCE(column, 'Default') to replace potential NULL values with clean, readable fallback strings before presenting reports to executives.
  • What NOT to Do: Never write WHERE column = NULL. It is a classic beginner trap that will silently return zero rows without throwing a syntax error!
  • Syntax & Pro Tips
    SELECT name, genre 
    FROM artists a 
    LEFT JOIN songs s ON a.id = s.artist_id 
    WHERE s.id IS NULL;
    Interactive Sandboxed Terminal (Preloaded DB Schema: SPOTIFYLITE)
    SQL Query WorkspaceSQLite v3.45 (WASM Mode)
    QUICK INSERT:
    1