Here\'s a simplified example of what I\'m talking about:
Table: students exam_results _____________ ____________________________________ | id | name |
SELECT s.name, COALESCE(MAX(er.score), 0) AS high_score FROM STUDENTS s LEFT JOIN EXAM_RESULTS er ON er.student_id = s.id GROUP BY s.name