How to select all exams by its ID and title (from table 'exams'), that a student (in table 'grades') hasn't written yet?
TABLE: grades
+--------------+----+---- |student_number|e_id| ... +--------------+----+---- |888075 |1 | ... |888075 |2 | ... |888075 |4 | ... |637020 |2 | ... +--------------+----+---- TABLE: exams
+----+------+ |e_id|title | +----+------+ |1 |exam 1| |2 |exam 2| |3 |exam 3| |4 |exam 4| +----+------+ In this particular case I would expect the following output for student 888075:
+--+------+ |id|title | +--+------+ |3 |exam 3| +--+------+ I just need the inverse selection of this:
SELECT e.e_id as id, e.title as title FROM grades g LEFT JOIN exams e ON g.e_id = e.e_id WHERE g.student_number = '888075'