CREATE TABLE personfriend (name CLOB, friend CLOB, year NUMBER)
CREATE TABLE person (name CLOB, age NUMBER, city CLOB, gender CLOB, job CLOB)

Find Alice's friends of friends.
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'
SELECT DISTINCT "T4"."name" FROM "personfriend" "T1" JOIN "person" "T2" ON "T1"."name" = "T2"."name" AND "T2"."name" = 'Alice' JOIN "personfriend" "T3" ON "T1"."friend" = "T3"."name" JOIN "personfriend" "T4" ON "T3"."friend" = "T4"."name" AND "T4"."name" <> 'Alice'