Attempting to create a mutual friend list

Hi there,

I’m having trouble with some SQL logic for mutual friends.

Say I have 2 variables, user1, and user2. What can I do to find out the mutual friends of these two users?

My friends table is:

friend1, friend 2, requestor and status.

When someone is a friend with each other the entry goes both ways. So.
friend1 = user1, friend2 =user2 AND friend1 = user2, friend2 = user1.

Now how can I find a mutual friend? How can I take user1 = friend1 and take friend2 to check whether user2 is friends with friend2?

Thanks for your help.

More specifically I was wondering whether there was any “IN COMMON” SQL commands.

I’m a beginner at this, so someone else can confirm or negate whether or not this method is advisable:

If user1 and user2 are friends, and user2 goes to user1’s page, pull the friends of user1 and user2 and compare them against each other in a loop. Then display the ones (if any) that are equal to one another (i.e. mutual friends).