samedi 16 juillet 2016

How does the correlation name work in the inner query?

I have a query to "Find all courses taught in both the Fall 2009 semester and in the Spring 2010 semester" as

SELECT
    course_id
FROM
    section S
WHERE
    semester = 'Fall'
AND YEAR = 2009
AND EXISTS (
    SELECT
        *
    FROM
        section T
    WHERE
        semester = 'Spring'
    AND YEAR = 2010
    AND S.course_id = T.course_id
);

In the second part of the where clause of the inner query you could see S.course_id=T.course_id. What is S.course_id? Is that the course_id of the relation produced by the outer query ?

Aucun commentaire:

Enregistrer un commentaire