Find Alice's friends of friends.
create table personfriend (name varchar, PRIMARY KEY (name)); create table personfriend (name varchar, friend varchar, PRIMARY KEY (name)); create table person (name varchar, PRIMARY KEY (name))
select distinct t4.name from personfriend as t1 join person as t2 on t1.name = t2.name join personfriend as t3 on t1.friend = t3.name join personfriend as t4 on t3.friend = t4.name where t2.name = 'alice' and t4.name <> 'alice'