Welcome to the Treehouse Community
Looking to learn something new?
Noah Fields13,985 Points
My version of the answer with subqueries
Here's my version of the code, using subqueries.
-- Generate a schedule for Rex Rios. SELECT NAME AS Class, PERIOD_ID AS Period FROM SCHEDULE INNER JOIN (CLASSES) ON CLASSES.ID = CLASS_ID --Find classes where the class ID in classes = schedule ID INNER JOIN SUBJECTS ON CLASSES.SUBJECT_ID = SUBJECTS.ID -- Join to subjects where the classes subject ID = Subject ID WHERE STUDENT_ID IN ( SELECT ID FROM STUDENTS WHERE FIRST_NAME = 'Rex' AND LAST_NAME = 'Rios' --But only for those where the schedule's ID colum matches Rex's ID ) ORDER BY PERIOD_ID --Order by period for neatness