+ All Categories
Home > Documents > -- Cartesian Product : Product Join without Where Clause...

-- Cartesian Product : Product Join without Where Clause...

Date post: 25-Sep-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
4
-- Cartesian Product : Product Join without Where Clause select * from employee, department; select COUNT(*) from employee, department;
Transcript
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;


Recommended