title: empty result while joining three tables mysql
body: <p>Hi all I have the following query </p>
  
  <pre><code>SELECT MAX(s.nextPass), st.ID, st.fio 
  FROM recomission s 
  JOIN recomission_to_student b 
       ON s.ID = b.recomission_id 
  JOIN student st 
       ON  b.student_id = st.id 
  JOIN education_to_student e 
       ON s.ID = e.education_id 
  JOIN education ed 
       ON  e.student_id = ed.id 
  WHERE s.nextPass BETWEEN  '2015-11-09' AND  '2016-02-09'
  GROUP BY st.fio
  </code></pre>
  
  <p>The tables are: recomission, student and education they are related using bridge tables lide recomission_to_student, education_to student. The query works just fine until I am trying to fetch departmant from education table but then I do it query returns null. I do understand that I somewhere close to desition but still can't figureout what to do.</p>
  
  <p>as for now trying to bypass the problem using subquery instead of join</p>
  
  <pre><code>SELECT MAX(s.nextPass), st.ID, st.fio 
  FROM recomission s 
  JOIN recomission_to_student b 
       ON s.ID = b.recomission_id 
  JOIN student st 
       ON  b.student_id = st.id 
  
  WHERE (select education_id where student_id=st.ID) and  s.nextPass BETWEEN  '2015-11-09' AND  '2016-02-09'
  </code></pre>
  
  <p>and getting the following error
  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where student_id=st.ID)' at line 8</p>