Skip to content
Justice Tech School

Sanity Checks

Compare counts before and after joins to catch duplicated rows.

Example
SELECT (SELECT COUNT(*) FROM students) AS students,
       (SELECT COUNT(*) FROM students s JOIN enrolments e ON e.student_id = s.id) AS after_join;

Result

students | after_join
8        | 8

Exercise

Count rows.

SELECT (*) FROM t

Quiz Test

Why compare counts after joins?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.