Author Question: What is a correlated subquery? Include an example. What will be an ideal ... (Read 24 times)

mpobi80

  • Hero Member
  • *****
  • Posts: 519
What is a correlated subquery? Include an example.
 
  What will be an ideal response?

Question 2

To access documentation about the MySQL Workbench, use the:
 
  A) Help  MySQL Workbench command.
  B) Help  Help Index command.
  C) Help  MySQL Website command.
  D) Help  MySQL.com Website command.
  E) Help  Documentation command.



patma1981

  • Sr. Member
  • ****
  • Posts: 292
Answer to Question 1

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 S
WHERE EXISTS
(SELECT
FROM FACULTY F
WHERE F.FacultyID = S.AdvisorID AND F.LastName = 'Smith'));

Answer to Question 2

B



Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
 

Did you know?

Drying your hands with a paper towel will reduce the bacterial count on your hands by 45–60%.

Did you know?

Critical care patients are twice as likely to receive the wrong medication. Of these errors, 20% are life-threatening, and 42% require additional life-sustaining treatments.

Did you know?

Glaucoma is a leading cause of blindness. As of yet, there is no cure. Everyone is at risk, and there may be no warning signs. It is six to eight times more common in African Americans than in whites. The best and most effective way to detect glaucoma is to receive a dilated eye examination.

Did you know?

Parkinson's disease is both chronic and progressive. This means that it persists over a long period of time and that its symptoms grow worse over time.

Did you know?

Drug-induced pharmacodynamic effects manifested in older adults include drug-induced renal toxicity, which can be a major factor when these adults are experiencing other kidney problems.

For a complete list of videos, visit our video library