Facebook style friendlist

hi there,

I’ve been making a small social media app and as most social media apps it must have a friends list. I’ve organized my friends table very simply. It contains 3 fields: id, friend1, friend2. I’m not certain this is the best method but so I’ve been told.

I know very basic MySQL but trying to learn more advanced combinations of sql functions. What I want to achieve is selecting all the friend1 or friend2 that is not = to username but the username must be one of friend1 or friend2.

I’m also trying to join tables, to obtain the user data, so SELECT username, picture from the database.

Could anyone point me in the right direction?

It would be greatly appreciated.

The id field is not necessary. you’d have an id for Friend1 and an id for Friend2, the additional id field offers no necessary information.

Did you search the forum for FRIEND since the question is likely to have been asked and answered a number of times?

Woops. Sorry about that. Haven’t been using sitepoint in a while. Got my answer. Thanks