title: Accessing data in table pointed to by foreign key
body: <p>I have the following query in MySQL:</p>
  
  <pre><code>select first_name, idStudent2
  from `Student` join `Friend`
  on `Student`.`idStudent` = `Friend`.`idStudent1`;
  </code></pre>
  
  <p>it gives the result</p>
  
  <pre><code>Camille   1
  Emily     5
  Bob       6
  Bob       7
  ...
  </code></pre>
  
  <p>The result is showing the student name, and then the student-ID of a friend of that student.</p>
  
  <p>The table named <code>Student</code> is a table of all the students in a (school) database. <code>Friend</code> is a unary Many-to-Many relationship on student. </p>
  
  <p>Instead of the result showing the student-ID in the second column, I would like it to show the student name that corresponds to that ID. </p>
  
  <p><code>idStudent1</code> and <code>idStudent2</code> are foreign key pointing to the primary key of the <code>Student</code> table. So basically, I want a means of accessing the information in the table row that the foreign key <code>idStudent2</code> points to.</p>
  
  <p>The desired result would look something like this:</p>
  
  <pre><code>Camille    Trevor
  Emily      Bob
  Bob        James
  Bob        Katrina
  ...
  </code></pre>