title: MySQL Command Line Client: Selecting records from a table which links two other tables
body: <p>I have three tables. Two of them are separate irrelevant tables (students and subjects), the third (entries) is one which links them both with foreign keys (student_id and subject_id). </p>
  
  <p>Here are all the tables with the records:</p>
  
  <p>students:</p>
  
  <pre><code>+------------+------------+-----------+---------------------+----------------------+
  | student_id | first_name | surname   | email               | reg_date             |
  +------------+------------+-----------+---------------------+----------------------+
  |          1 | Emma       | Harvey    | emmah@gmail.com    | 2012-10-14  11:14:13 |
  |          2 | Daniel     | ALexander | daniela@hotmail.com | 2014-08-19  08:08:23 |
  |          3 | Sarah      | Bell      | sbell@gmail.com     | 1998-07-04  13:16:32 |
  +------------+------------+-----------+---------------------+--------------- ------+
  </code></pre>
  
  <p>subjects:</p>
  
  <pre><code>+------------+--------------+------------+----------------+
  | subject_id | subject_name | exam_board | level_of_entry |
  +------------+--------------+------------+----------------+
  |          1 | Art          | CCEA       | AS             |
  |          2 | Biology      | CCEA       | A              |
  |          3 | Computing    | OCR        | GCSE           |
  |          4 | French       | CCEA       | GCSE           |
  |          5 | Maths        | OCR        | AS             |
  |          6 | Chemistry    | CCEA       | GCSE           |
  |          7 | Physics      | OCR        | AS             |
  |          8 | RS           | CCEA       | GCSE           |
  +------------+--------------+------------+----------------+    
  </code></pre>
  
  <p>entries:</p>
  
  <pre><code>+----------+---------------+---------------+------------+
  | entry_id | student_id_fk | subject_id_fk | entry_date |
  +----------+---------------+---------------+------------+
  |        1 |             1 |             1 | 2012-10-15 |
  |        2 |             1 |             4 | 2011-09-21 |
  |        3 |             1 |             3 | 2015-08-10 |
  |        4 |             2 |             6 | 1992-07-13 |
  |        5 |             3 |             7 | 2013-02-12 |
  |        6 |             3 |             8 | 2016-01-14 |
  +----------+---------------+---------------+------------+
  </code></pre>
  
  <p>I want to know how to select all the <em>first_name</em>s of the students in the <em>students</em> table, who have entries with a with the OCR <em>exam_board</em> from the <em>subjects</em> table, using the <em>entries</em> table.
  I'm sure it has to do with joins, but which one to use and the general syntax of it, I don't know.</p>
  
  <p>I'm generally awful at explaining things, so sorry if these doesn't make a ton of sense and if I've missed out something important. I'll gladly go into more specifics if necessary.</p>
  
  <p>I've got an answer, but what I was looking for as the output was this:</p>
  
  <pre><code>+------------+
  | first_name |
  +------------+
  | Emma       |
  | Sarah      |
  +------------+
  </code></pre>