JA

Use One Table in Two Roles

A self join gives one table two aliases and treats them as separate table references. Alias customers as customer c and referrer ref, then match c.referred_by with ref.id to place both names in one row.

Bob's referred_by is 1. Who is Bob's referrer?