In your own words discuss the difference between a subquery

In your own words, discuss the difference between a subquery and a correlated subquery and how or when each should be used in MySQL.

Solution

Correlated queries: Correlated queries is also a sub query which uses values from the outer query. So for every row of outer query and inner query will be executed.

Let me share with you an example of typical correlated query for better understanding of the question.

in the above given example the outer query is

and the inner query or correlated sub query is

In the above nested query the inner query has to be re-executed for each user.

Subquery: Unlike correlated query subquery is executed only once and gives the output to the outer query and then the outer query is executed.

select * from user_profile where uid in ( select name from library);

One more example for simple query is given below:

I hope subquery and correlated is clear by these elaborated examples, buti f you still have doubt please comment below.

In your own words, discuss the difference between a subquery and a correlated subquery and how or when each should be used in MySQL.SolutionCorrelated queries:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site