MySQL query select rows from table according to specific key that is not in another table -
how select exams id , title (from table 'exams'), 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 particular case expect following output student 888075
:
+--+------+ |id|title | +--+------+ |3 |exam 3| +--+------+
i need inverse selection of this:
select e.e_id id, e.title title grades g left join exams e on g.e_id = e.e_id g.student_number = '888075'
your query close -- reverse joins , check null
accordingly:
select e.e_id id, e.title title exams e left join grades g on g.e_id = e.e_id , g.student_number = '888075' g.e_id null
Comments
Post a Comment