David Hugh-Jones writes:
> The student table has an "average grade" column which shows that student's > average grade last year. The "grades" table has a column for subject (e.g. > English, Math) and a column for the grade achieved. > > Suppose I want to select all my students who have performed very well this > year. I want to select all the students who have beaten last year's average > in ALL of this years marks! This sounds like a LEFT JOIN problem. You want all students who have 0 grades that are below or equal to last year's average, right? Something like "SELECT DISTINCT s.id FROM students s LEFT JOIN grades g ON g.id=s.id AND g.grade > s.average AND g.year=2000" ought to do the trick. //C -- Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/ Amiga user since '89, and damned proud of it too. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php