Nested Queries
Nested Queries
Database Systems
SUBQUERY/NESTED
QUERY
Database Systems
What is Indexing?
• Indexing makes columns faster to query by creating
pointers to where data is stored within a database.
What is Indexing?
Database Systems
SUBQUERY
• department table
Employee table
• Suppose you want to find out the ename, job,sal of the
employees whose salaries are less than that of an employee
whose empno= 7876 from EMP table. Now you need to perform
two queries in order to get the desired result.
1. We will find out the salary of the employee whose
empno=7876. the query is as under:
SYMBOL MEANING
salary
SELECT of their
e.emp_id, department?
e.dept_id,
201
114
20 Hartstein
30 Raphaely
13000
11000
e.last_name, e.salary 123 50 Vollman 6500
122 50 Kaufling 7900
FROM employees e 120 50 Weiss 8000
WHERE e.salary > (SELECT avg(i.salary) 121 50 Fripp 8200
103 60 Hunold 9000
FROM employees i 147 80 Errazuriz 12000
WHERE e.dept_id = i.dept_id) 146 80 Partners 13500
145 80 Russell 14000
100 90 King 24000
108 100 Greenberg 12000