Jason Chan wrote:

>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?
>
>
>
>
>
>
>
>
select s.StudentID , s.StudentName
from Student as s , SubjectGrade as sj
where s.studentID = sj.studentID and sj.Grade = 'A' and (sj.Subject =
'Maths' or sj.Subject = 'Chem')

I think your query will return student 3 as well




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to