Explain sub-queries in brief

Explain sub-queries in brief.

A sub-query is a query within a query. It is embedded within the WHERE clause of the first query. It is used to return data that is used in main query as a condition.

Example:
To return salary for the employee’s id in employee table.
Select emp_id, emp_name from employee
Where emp_id IN (select emp_id FROM salary);

Explain sub-queries in brief.

Sub-query is the technique that lets us use the result of one query as part of another query. Sub-queries are very simple to implement and understand. Some queries can't be solved without sub queries.
Different operators used in building sub queries
Following operators can be used in building sub queries: IN: Allows multiple values to be checked. EXIST: Checks if a value exists......
What are the guidelines for using SUB-QUERIES?
Following things need to be kept in mind when you write sub-queries: Caution should be taken with simple sub-query, especially when a normal value operator is used on the results of a sub-query, only one field must be returned....
What is correlated sub-query?
In a simple SubQuery, the result retrieved by the inner query is fed to the outer query. The outer query takes the result as its input and processes it to produce its output....
Post your comment