title: 2 Foreign Keys referencing the same Primary Key in MySQL
body: <p>like so:</p>
  
  <p>Table-student:</p>
  
  <p>sID | name</p>
  
  <p>1 -----susan</p>
  
  <p>2 -----morgan</p>
  
  <p>3 -----Ian</p>
  
  <p>4 -----james</p>
  
  <p>Primary key = sID</p>
  
  <p>the other table like so:</p>
  
  <p>Table- friends</p>
  
  <p>friendsID | personA   |  personB</p>
  
  <p>1-----------1-----------3</p>
  
  <p>2------------1-----------2</p>
  
  <p>3-------------2-----------3</p>
  
  <p>4-------------3------------4</p>
  
  <p>Where Primary Key is: friendsID, personA, personB</p>
  
  <p><strong>Foreign Key</strong> = personA, personB which both refer to <strong>sID</strong> in students table</p>
  
  <p>I want a way of querying the friends table in such a way that the personA and personB coloumn are replaced by name via sID. I tried natural join but it only works if there is one foreign key.</p>
  
  <p>i.e. Im looking for something like this:</p>
  
  <p>friendsID | personA   |  personB</p>
  
  <p>1-----------Susan-----------Ian</p>
  
  <p>2------------Sushan-----------Morgan</p>
  
  <p>3-------------morgan-----------Ian</p>
  
  <p>4-------------Ian------------james</p>
  
  <p>the Natural join would work if I only had personB as a column and no personB. For some reason the natural join is huge when I do:
  select*from friends NATURAL JOIN student;</p>
  
  <p>Please help. Thanks </p>