title: Get row values from foreign key MySQL
body: <p>This may sound simple and dumb but how can I get the values of a <code>foreign</code> key from a table and displaying it?</p>
  
  <p>I have a table named "<code>subjects</code>" which contains different school subjects and one column of it is a <code>foreign</code> key referencing from table named "<code>faculty</code>".</p>
  
  <pre><code>TABLE subjects
  ___________________________________
  | sub_id | sub_faculty | sub_desc |
  |    1   |      2      | PHYSICS  |
  |    2   |      3      |   MATH   |
  |    3   |      4      | HISTORY  |
  |________|_____________|__________|
  
  TABLE faculty
  ________________________
  | fac_id |  fac_name   |
  |    2   |    John     |
  |    3   |    Mark     |
  |    4   |   Johnny    |
  |________|_____________|
  </code></pre>
  
  <p>I firstly wanted to check if data exist in the "<code>subject</code>" table and then proceed on displaying the row values of the <code>foreign key</code>.</p>
  
  <p>I have this not so working query as displays both <code>JOHN</code> and <code>JOHNNY</code>. I was using <code>LIKE</code> as it will be for the search feature of the system so hopefully you can help me out on this.</p>
  
  <pre><code>SELECT * 
  FROM subject, faculty 
  WHERE subject.sub_desc = 'PHYSICS' 
    AND subject.sub_year = '4' 
    AND faculty.fac_name LIKE '%JOHN%' 
  GROUP BY faculty.fac_id
  </code></pre>