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

Limit intake of red meat and dairy products made with whole milk. Choose skim milk, low-fat or fat-free dairy products. Limit fried food. Use healthy oils when cooking.

Did you know?

More than one-third of adult Americans are obese. Diseases that kill the largest number of people annually, such as heart disease, cancer, diabetes, stroke, and hypertension, can be attributed to diet.

Did you know?

About one in five American adults and teenagers have had a genital herpes infection—and most of them don't know it. People with genital herpes have at least twice the risk of becoming infected with HIV if exposed to it than those people who do not have genital herpes.

Did you know?

Increased intake of vitamin D has been shown to reduce fractures up to 25% in older people.

Did you know?

Warfarin was developed as a consequence of the study of a strange bleeding disorder that suddenly occurred in cattle on the northern prairies of the United States in the early 1900s.

For a complete list of videos, visit our video library