CELKO (10/12/2012)
Then try this query:SELECT student_id
FROM Gradebook
GROUP BY student_id
HAVING (MIN(course_1)= MAX(course_1) AND MIN(course_1) = 'fail')
OR (MIN(course_2)= MAX(course_2) AND MIN(course_2) = 'fail')
OR (MIN(course_3)= MAX(course_3) AND MIN(course_3) = 'fail');
Oh, great. A solution that works solely because you have only two years data, and they are two successive years. The original post made the point that the two fails have to be in consecutive years, which suggests fairly strongly that the problem isn't limited to two consecutive years (since if it were, that point would have no consequences for the solution).
And sloppy coding: insert tablename values.... instead of insert tablename9<column list>) values...
And choosing a string representation of a year number that is a bizarre contrivance from MySql instead of using an integer, or a natural string rtepresentation of a number.
You can do better than that, JC!
Tom