Hi, Today I discuss about important topics - Sub Query and Co- Related Query.
Subquery:
Subqueries are the queries inside a query. Subqueries can be made using WHERE, FROM or SELECT clause.
Query
(Subquery);
Example:
select * from students
where student_id IN
(select student_id
from students
where student_type = 'Day Scholar');
It first perform subQuery and then outer query.
Above Display display student details whose is 'Day Scholar'.
Co Related Query:
A correlated SQL subquery is just a subquery that is executed many times—once for each record (row) returned by the outer (main) query. In other words, the outer query returns a table with multiple rows; the inner query then runs once for each of those rows. If your outer query returns 10 rows, then the inner query will run 10 times. And if your outer query returns 100 rows, the inner query will run 100 times.
Thank you for reading .Feel Free to ask you Query in comment section.