title: MYSQL/PHP table design for friends table/query to select friends
body: <p>For a social network site, I have a table with the ids of the inviter and the invitee and the status of the invitation ie accepted or not.  According to what I've read, this seems to be best practice for a friends table.  </p>
  
  <p>Table friends</p>
  
  <pre><code>id | inviterid |inviteeid |status
  </code></pre>
  
  <p>however, for a given userid, I want to display all the "friends" the person has including their names. I can get a list of records of relationships with a simple query</p>
  
  <pre><code>Select * from friends WHERE inviterid = '33' or inviteeid = '33'"
  </code></pre>
  
  <p>But, this does not translate easily into a list of friends, since the friends could be either inviters or invitees so the field will be different depending on who invited whom.</p>
  
  <p>Is there a better table design for a friends table?  Alternatively, is there a sql syntax that would select friends who can be either inviters and invitees.  Ultimately, I need to do a join to another table that has the users names.</p>