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

Atropine was named after the Greek goddess Atropos, the oldest and ugliest of the three sisters known as the Fates, who controlled the destiny of men.

Did you know?

According to the American College of Allergy, Asthma & Immunology, more than 50 million Americans have some kind of food allergy. Food allergies affect between 4 and 6% of children, and 4% of adults, according to the CDC. The most common food allergies include shellfish, peanuts, walnuts, fish, eggs, milk, and soy.

Did you know?

Methicillin-resistant Staphylococcus aureus or MRSA was discovered in 1961 in the United Kingdom. It if often referred to as a superbug. MRSA infections cause more deaths in the United States every year than AIDS.

Methicilli ...
Did you know?

Cucumber slices relieve headaches by tightening blood vessels, reducing blood flow to the area, and relieving pressure.

Did you know?

Human neurons are so small that they require a microscope in order to be seen. However, some neurons can be up to 3 feet long, such as those that extend from the spinal cord to the toes.

For a complete list of videos, visit our video library