Table Joins

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

TABLE JOINS

Join Queries
SQL joins is used to combine 2 tables or more tables based
on the column that is related / common in between them
Table: Department
DNo Dname Location
1 Registration Colombo
2 Management Kandy
3 Marketing Colombo
4 Research Galle
5 Accounts Matara
6 IT Colombo
Table: Employee
EmpNo Ename Job Salary Commission DeptNo
1 Amal Clerk 20000 100 2
2 Kamal Analyst 60000 100 4
3 Nimal Manager 50000 520 3
4 Sarah Clerk 20000 100 1
5 Nirupa Accountant 40000 100 5
6 Sahan Technician 10000 110 6
SELECT e.Ename, e.Salary, d.Dname
FROM Employee e, Department d
WHERE e.DeptNo= d.Dno
1. Display employee name and the Department name of employees
whose salary is greater than 25,000
2. print all the employee names and the Department names who are
working on Colombo
3. print names of employees working for IT department
4. print names of employee working for IT Department and getting
more than 30,000 salary
1. SELECT E.ename, D.dname
FROM employee E, department D
WHERE E.deptno=D.dno AND E.salary>25000

2. SELECT E.ename, D.dname


FROM employee E, department D
WHERE E.deptno=D.dno AND D.location='Colombo’

3. select E.ename
from employee E, department D
where E.deptno=D.dno and D.dname=‘IT’

4. select E.ename
from employee E, department D
where E.deptno=D.dno and D.dname='IT' AND E.salary>30000
THANK YOU

You might also like