human
Schema:
Allergy_Type (Allergy, AllergyType)
Has_Allergy (StuID, Allergy)
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Please answer with SQL.
assistant
Sure, I understand.
human
Which students are allergic to cats?
assistant
SELECT StuID FROM Has_allergy WHERE Allergy = 'Cat';
human
Which students are not?
assistant
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = 'Cat';
human
Of these, list the first name and sex of students who are allergic to milk.
assistant
SELECT fname , sex FROM Student WHERE StuID IN ( SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat" ) ;