Hi,
I'm trying to write a simple query involving two tables. The "person" table has a unique person_id and a name, and the "friends" table has a person_id and a friend_id which is a FK to a person_id in the person table.
person: int person_id varchar[45] name
friends: int person_id int friend_id
I want to select the name of all of person 1's friends.
I can do this easily using an IN statement: SELECT p.name FROM person p WHERE p.person_id IN (SELECT f.friend_id FROM friends f WHERE f.person_id = 1);
However, I am not proficient at writing JOIN statements. Can somebody help me write the equivalent join?
Clearly this is a contrived example, but I have tried with my real data and am conceptually missing something. Thanks.