4
-- Cartesian Product : Product Join without Where Clause select * from employee, department; select COUNT(*) from employee, department;

-- Cartesian Product : Product Join without Where Clause ...cis.csuohio.edu/~sschung/cis430/ExampleSQL_1.pdf · - Cartesian Product Product Join without NIESW7\Sunnie (55)) Where

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: -- Cartesian Product : Product Join without Where Clause ...cis.csuohio.edu/~sschung/cis430/ExampleSQL_1.pdf · - Cartesian Product Product Join without NIESW7\Sunnie (55)) Where

-- Cartesian Product : Product Join without Where Clause

select * from employee, department;

select COUNT(*) from employee, department;

Page 2: -- Cartesian Product : Product Join without Where Clause ...cis.csuohio.edu/~sschung/cis430/ExampleSQL_1.pdf · - Cartesian Product Product Join without NIESW7\Sunnie (55)) Where

-- 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;

Page 3: -- Cartesian Product : Product Join without Where Clause ...cis.csuohio.edu/~sschung/cis430/ExampleSQL_1.pdf · - Cartesian Product Product Join without NIESW7\Sunnie (55)) Where

-- 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;

Page 4: -- Cartesian Product : Product Join without Where Clause ...cis.csuohio.edu/~sschung/cis430/ExampleSQL_1.pdf · - Cartesian Product Product Join without NIESW7\Sunnie (55)) Where

--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;