Select s.StudentID, s.StudentName from Student s, SubjectGrade sg where s.StudentID = sg.StudentID and sg.Subject = 'Maths' and sg.Subject = 'Chem' and sg.Grade = 'A'
The key here is using the aliases for the tables. The linking of the tables comes in the s.StudentID = sg.StudentID statement. I am using mysql 4.0.25 with no subquery support : ( "Jason Chan" <[EMAIL PROTECTED]> �b�l�� news:[EMAIL PROTECTED] �����g... I have a student Table and a SubjectGrade table Create Table Student( StudentID INT NOT NULL, StudentName VARCHAR(30) ) Create Table SubjectGrade( StudentID INT NOT NULL, Subject VARCHAR(30) NOT NULL, Grade CHAR(1) ) let's say have following record in SubjectGrade 1 Maths A 1 Phys B 1 Chem A 2 Maths A 2 Chem A 3 Bio C 3 Chem A I want to find out students who have got A in both Maths and Chem How the SQL look like? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- Have a great day, Dan Julson Application Software Engineer API Outsourcing 1355 Mendota Heights Rd. Mendota Heights, MN 55120 651-675-2628 (work) 952-456-2067 (mobile) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]