Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShreemangal Sethi
Full Stack JavaScript Techdegree Student 15,552 PointsI am not able to understand how to link the table? Can someone explain me please.
For this particular question my query statement was
"SELECT ROOMS.ID, MIN(CAPACITY) * 7, STUDENTS.GRADE FROM ROOMS JOIN CLASSES ON ROOMS.ID = CLASSES.ROOM_ID JOIN SCHEDULE ON CLASSES.ID = SCHEDULE.CLASS_ID JOIN STUDENTS ON STUDENTS.ID = SCHEDULE.STUDENT_ID WHERE GRADE = 6;"
Can someone explain me where i am wrong. Thanks
1 Answer
Steven Parker
231,236 PointsYou're constraining the value by including tables not needed for this query. In particular, you don't need SCHEDULE or STUDENTS since we're not concerned with any specific student or time of day. But JOIN SUBJECTS instead (as the reference to GRADE) and you'll get the correct result.
SELECT ROOMS.ID, MIN(CAPACITY) * 7, GRADE
FROM ROOMS
JOIN CLASSES ON ROOMS.ID = CLASSES.ROOM_ID
JOIN SUBJECTS ON SUBJECTS.ID = CLASSES.SUBJECT_ID
WHERE GRADE = 6