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

Throughout history, plants containing cardiac steroids have been used as heart drugs and as poisons (e.g., in arrows used in combat), emetics, and diuretics.

Did you know?

Tobacco depletes the body of vitamins A, C, and E, which can result in any of the following: dry hair, dry skin, dry eyes, poor growth, night blindness, abscesses, insomnia, fatigue, reproductive system problems, sinusitis, pneumonia, frequent respiratory problems, skin disorders, weight loss, rickets, osteomalacia, nervousness, muscle spasms, leg cramps, extremity numbness, bone malformations, decayed teeth, difficulty in walking, irritability, restlessness, profuse sweating, increased uric acid (gout), joint damage, damaged red blood cells, destruction of nerves, infertility, miscarriage, and many types of cancer.

Did you know?

More than 30% of American adults, and about 12% of children utilize health care approaches that were developed outside of conventional medicine.

Did you know?

When blood is deoxygenated and flowing back to the heart through the veins, it is dark reddish-blue in color. Blood in the arteries that is oxygenated and flowing out to the body is bright red. Whereas arterial blood comes out in spurts, venous blood flows.

Did you know?

Everyone has one nostril that is larger than the other.

For a complete list of videos, visit our video library