Sub query:
A Query within the where clause or A select query within another select query is called sub query.
Example : Select * from employee where dno=(select dno from department);
Types :
Inner Query : A Query within the where clause or A select query within another select query is called sub query.
Example : Select * from employee where dno=(select dno from department);
Types :
- Inner or Normal sub query.
- Correlated sub query.
- If sub query executed only once and returns single values. It is called Inner query.
- Uses operator =,<,>,<> etc.
Example : select * from employee where dno=(select max(dno) from department);
Correlated Query :
- If sub query returns multiple values then it is correlated sub query.
- Uses opeartors In,Not In, All, Any etc.
Select e.name,e.no,e.salary from employee e where salary=(select max(salary) from employee b where e.dno=b.dno group by b.dno):
Inline View :
Select query within the from clause instead of table or object name.
Example : Select * from (Select name,no,salary from employee);
0 comments:
Post a Comment