co-related sub-query with example

Creating Simple Queries, Hierarchical Queries, Sorting Query Results, Joins, Unnesting of Nested Subqueries and Distributed Queries.
Post Reply
AyubHussain
Posts: 138
Joined: Fri Nov 23, 2018 2:48 am

co-related sub-query with example

Post by AyubHussain » Tue Dec 04, 2018 6:14 am

Explain co-related sub-query with example?

dsusmitha
Posts: 62
Joined: Fri Nov 23, 2018 2:51 am

Re: co-related sub-query with example

Post by dsusmitha » Tue Dec 04, 2018 6:15 am

Fetch the Employees who have not assigned a single department.

Select * from Employee E where Not exist

(Select Department_no From Department D where E.Employee_id=D.Employee_ID);

Execution of query:

Step 1:

Select * from Employee E ;

It will fetch the all employees

Step 2:

The First Record of the Employee second query is executed and output is given to first query.

(Select Department_no From Department D where E.Employee_id=D.Employee_ID);

Step 3:

Step 2 is repeated until and unless all output is been fetched.

Post Reply

Return to “SQL Queries and Subqueries”