SQSQL · Lesson 5 of 8
JOINs — Combining Tables
Real databases split data across many tables: students in one, courses in another, enrollments linking them. JOIN stitches them back together. This is the concept that makes databases 'relational'.
Instead of one giant table repeating the course name on every student row, you store courses once and reference them by id. A JOIN matches rows from two tables using a condition — almost always 'foreign key equals primary key'.
◆ Note
The single-letter names (students s) are table aliases — pure convenience for shorter queries. Also note NULL checks use IS NULL / IS NOT NULL, never = NULL. NULL isn't equal to anything, not even itself.
The single-letter names (students s) are table aliases — pure convenience for shorter queries. Also note NULL checks use IS NULL / IS NOT NULL, never = NULL. NULL isn't equal to anything, not even itself.