SUB QUERIES :–
- A query embeded in another query is called “sub querry”.
- In this ,there will be two queries,one queries called inner-query and another query is called outer query.
- When it is executed,first inner query is executed then outer query
- The result of inner query act as input to outer query.
Types of sub queries :-
- standard sub queries [follows where clause]
- derived tables [follows from clause]
- scalar subqueries [follows select clause]
Standard sub queries :–
- Subqueries follows where clause (or) standard subquries.
- Outer query can be insert, Update, Delete, Select
- Inner query must be always select.
Syntax :– Select <collist> from <tabname> where colname operation[select statement]
- Use subqueries when where clause is based on unknown condition.
Types of standard subqueries :-
- Single row subquery
- multi row subquery
- nested queries
- co-related subqueries