Alternatively, use an IN list for the subject, then use a HAVING clause
to limit the results to students with 2 matching rows, like this:
SELECT StudentID, StudentName
FROM Student s
JOIN SubjectGrade sg ON s.StudentID = sg.StudentID
WHERE sg.Subject IN ('Maths', 'Chem')
AND sg.Grade = 'A';
GROUP BY s.StudentID
HAVING COUNT(*) = 2;
What if the student has 2 result in maths (or 2 in chemistry) ??? ;-)
--
Philippe Poelvoorde
COS Trading Ltd.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]