Search⌘ K
AI Features

Solution: Connect Two Tables

Explore how to join two tables in SQL using the LEFT JOIN method to combine student records with their Math grades. Understand how to use table aliases, join conditions, and filtering to display all students with their corresponding grades or NULL values where grades are missing.

We'll cover the following...

Query

SELECT s.id, s.name, g.score AS math_grade
FROM students s
LEFT JOIN grades g
ON s.id = g.student_id AND g.subject = 'Math';

Explanation

This query shows each student along with their Math grade (if available). ...