0% found this document useful (0 votes)
294 views

Oracle Join Vs ANSI SQL Join Summary

The document compares Oracle proprietary join syntax to ANSI SQL compliant join syntax. It shows that Oracle uses commas between tables in a join, while ANSI SQL uses explicit JOIN keywords and ON clauses to link tables. It also explains different types of joins like inner joins, outer joins, self-joins and multi-table joins, and how they are written in both Oracle and ANSI SQL syntax.

Uploaded by

jcgutz3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
294 views

Oracle Join Vs ANSI SQL Join Summary

The document compares Oracle proprietary join syntax to ANSI SQL compliant join syntax. It shows that Oracle uses commas between tables in a join, while ANSI SQL uses explicit JOIN keywords and ON clauses to link tables. It also explains different types of joins like inner joins, outer joins, self-joins and multi-table joins, and how they are written in both Oracle and ANSI SQL syntax.

Uploaded by

jcgutz3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Oracle Proprietary Joins vs.

ANSI SQL Compliant Joins

Description Oracle Proprietary Join Syntax ANSI SQL Compliant Join Syntax
Produces cartesian CROSS JOIN:
product of joined
tables. select last_name, department_name select last_name, department_name
from employees, departments from employees CROSS JOIN departments
Joining table using EQUIJOIN: NATURAL JOIN:
similar columns
(foreign key -> select department_id, department_name, select department_id, department_name,
Primary Key). d.location_id, city location_id, city
from departments d, locations l from departments
where d.location_id = l.location_id NATURAL JOIN
locations
EQUIJOIN: To specify only one column (in case there are
more than one similar columns), natural join
with USING CLAUSE:

select last_name, department_name


select last_name, department_name from employees
from employees e, departments d JOIN
where e.department_id = d.department_id departments
USING (department_id)
EQUIJOIN: If columns have different name, natural join
with ON CLAUSE:

select e.employee_id, e.last_name, select e.employee_id, e.last_name,


e.manager_id, m.last_name "MANAGER'S e.manager_id, m.last_name "MANAGER'S
LAST NAME" LAST NAME"
from employees e, employees m from employees e
where e.manager_id = m.employee_id JOIN employees m
ON (e.manager_id = m.employee_id)
Joining tables using NON-EQUIJOIN ON CLAUSE:
arbitrary condition.
select e.last_name, e.salary, e.job_id, select e.last_name, e.salary, e.job_id,
j.job_title, j.min_salary, j.max_salary j.job_title, j.min_salary, j.max_salary
from employees e, jobs j from employees e JOIN jobs j
where e.salary BETWEEN j.min_salary AND ON (e.salary BETWEEN j.min_salary AND
j.max_salary j.max_salary)
order by last_name order by last_name

SELF-JOIN select e.employee_id, e.last_name, select e.employee_id, e.last_name,


e.manager_id, m.last_name "MANAGER'S e.manager_id, m.last_name "MANAGER'S
LAST NAME" LAST NAME"
from employees e, employees m from employees e
where e.manager_id = m.employee_id JOIN employees m
ON (e.manager_id = m.employee_id)
Three-way joins select employee_id, city, select employee_id, city, department_name
department_name from employees e
from employees e, departments d, JOIN departments d
locations l ON e.department_id = d.department_id
where e.department_id = d.department_id JOIN locations l
and d.location_id = l.location_id ON d.location_id = l.location_id

LEFT OUTER JOIN select e.last_name, e.department_id, select e.last_name, e.department_id,


d.department_name d.department_name
Displays values from from employees e, departments d from employees e
the table on the left, where LEFT OUTER JOIN departments d
even when there is no e.department_id = d.department_id(+) ON e.department_id = d.department_id
match found.
RIGHT OUTER JOIN select e.last_name, e.department_id, select e.last_name, e.department_id,
d.department_name d.department_name
Displays values from from employees e, departments d from employees e
the table on the right, where RIGHT OUTER JOIN departments d
even when there is no e.department_id(+) = d.department_id ON e.department_id = d.department_id
match found.
FULL OUTER JOIN select e.last_name, e.department_id,
d.department_name
Display values from from employees e
both sides even when Use UNION FULL OUTER JOIN departments d
there is no match ON e.department_id = d.department_id
found.

You might also like