Cartesian join

From Oracle FAQ

Jump to: navigation, search

A cartesian join is a join of every row of one table to every row of another table. This normally happens when no matching join columns are specified. For example, if table A with 100 rows is joined with table B with 1000 rows, a cartesian join will return 100,000 rows! Something to be avoided!

Note: A query must have at least (N-1) join conditions to prevent a cartesian product.

Examples

Using Oracle join syntax:

SELECT * FROM emp, dept;
SELECT * 
  FROM emp, dept
 WHERE dept.deptno = 10
   AND emp.sal > 10000;

Using ANSI join syntax:

SELECT * FROM emp CROSS JOIN dept;

Also see


Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #
Personal tools