Join Together

Listing 1. We can use joins to perform a query to find employees hired since 01/01/1998 for each of the concrete classes and return the combined results. Notice that we have to use a nested select to differentiate between Exempt and Manager employee types. Since MySQL doesn't support nested selects, this example would not work with MySQL. However, it will work with Oracle.

select p.name, p.dob, e.hiredate, e.ssn, ne.payrate 
  from PersonPart p, EmployeePart e, NonExemptPart ne,
  PartTimePart pt
  where hiredate >= "01/01/1998" and p.name = e.name 
  and p.name = ne.name and p.name = pt.name
select p.name, p.dob, e.hiredate, e.ssn, ne.payrate 
  from PersonPart p, EmployeePart e, NonExemptPart ne,
  FullTimePart ft
  where hiredate >= "01/01/1998" and p.name = e.name 
  and p.name = ne.name and p.name = ft.name
select p.name, p.dob, e.hiredate, e.ssn, ex.salary 
  from PersonPart p, EmployeePart e, ExemptPart ex,
  where hiredate >= "01/01/1998" and p.name = e.name 
  and p.name = ex.name and p.name not in (
  select name from ManagerPart)
select p.name, p.dob, e.hiredate, e.ssn, ne.payrate 
  from PersonPart p, EmployeePart e, ExemptPart ex,
  ManagerPart m
  where hiredate >= "01/01/1998" and p.name = e.name 
  and p.name = ex.name and p.name = m.name