Author Question: What is a correlated subquery? Include an example. What will be an ideal ... (Read 33 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?

Eating carrots will improve your eyesight. Carrots are high in vitamin A (retinol), which is essential for good vision. It can also be found in milk, cheese, egg yolks, and liver.

Did you know?

Elderly adults are living longer, and causes of death are shifting. At the same time, autopsy rates are at or near their lowest in history.

Did you know?

In most cases, kidneys can recover from almost complete loss of function, such as in acute kidney (renal) failure.

Did you know?

There are more nerve cells in one human brain than there are stars in the Milky Way.

Did you know?

The toxic levels for lithium carbonate are close to the therapeutic levels. Signs of toxicity include fine hand tremor, polyuria, mild thirst, nausea, general discomfort, diarrhea, vomiting, drowsiness, muscular weakness, lack of coordination, ataxia, giddiness, tinnitus, and blurred vision.

For a complete list of videos, visit our video library