SchoolA
, SchoolB
, and SchoolC
to get all possible combinations of students.WHERE
clause to filter out combinations where student_id
or student_name
is not distinct across the three students.student_name
from each table and alias them as member_A
, member_B
, and member_C
for the final output.erDiagram SchoolA { int student_id PK varchar student_name } SchoolB { int student_id PK varchar student_name } SchoolC { int student_id PK varchar student_name }