Post on 25-Sep-2020
-- Cartesian Product : Product Join without Where Clause
select * from employee, department;
select COUNT(*) from employee, department;
-- Selection with Join Condition select *
from Employee e, Department d
where e.dno = d.dnumber;
select e.fname, e.lname, e.dno, d.dname
from Employee e, Department d
where d.dname = 'research' and e.dno = d.dnumber;
-- Selection with Join Condition
select * from Employee e, Department d
where e.dno = d.dnumber;
--Projection Columns only
select e.fname, e.lname, e.dno, d.dname
from Employee e, Department d
where d.dname = 'research' and e.dno = d.dnumber;
--Self Join: Find all the Supervisor’s First names and Last Names
select S.Ssn, S.Fname, S.Lname, S.Dno
from Employee E, Employee S
where E.Super_ssn = S.Ssn;
--Self Join: Find Last name of Smith’s Supervisor
select S.Ssn, S.Fname, S.Lname, S.Dno from Employee E, Employee S
where E.Lname = 'Smith' and E.Super_ssn = S.Ssn;