Top Posters
Since Sunday
38
14
10
9
8
8
7
7
7
7
6
6
New Topic  
wrote...
Posts: 165
4 months ago
What is a correlated subquery? Include an example.
Source  Download
Database Processing: Fundamentals, Design, and Implementation
Edition: 15th
Authors:
Read 14 times
1 Reply
Replies
Answer verified by a subject expert
wrote...
Posts: 222
4 months ago
Sign in or Sign up in seconds to unlock everything.
A correlated subquery uses the standard SQL subquery structure of a SELECT statement (called the lower SELECT) within the WHERE clause of a controlling (or upper) SELECT. However, where a non-correlated subquery uses different tables in the upper and lower SELECTS, the correlated subquery uses the same table in both SELECTS. SQL aliases are used to provide different table names within the query. When a non-correlated subquery is processed, the lower SELECT is processed first, and the entire result set of the lower SELECT is passed to the upper SELECT. When a correlated subquery is processed, a nested processing is used where each individual result of the lower SELECT is returned one at a time to the upper SELECT for processing. Here is an example that finds the last names of all students advised by a faculty whose last name is 'Smith':
SELECT S.LastName
FROM Student as S
WHERE EXISTS
(SELECT *
FROM FACULTY as F
WHERE F.FacultyID = S.AdvisorID AND F.LastName = 'Smith'));
This verified answer contains over 290 words.
Related Topics
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers.
Learn More
Improve Grades
Help Others
Save Time
Accessible 24/7
  185 People Browsing
Related Images
 795
 793
 85

▶️ Video: Introduction to Diabetes

For a complete list of videos, visit our video library