Oracle Cross Join (Cartesian Products)

The CROSS JOIN specifies that all rows from first table join with all of the rows of second table. If there are "x" rows in table1 and "y" rows in table2 then the cross join result set have x*y rows. It normally happens when no matching join columns are specified.

In simple words you can say that if two tables in a join query have no join condition, then the Oracle returns their Cartesian product.

Syntax

Or

Both the above syntax are same and used for Cartesian product. They provide similar result after execution.

Image representation of cross join

Oracle Cross Join

Oracle Cross Join Example

Let's take two tables "customer" and "supplier".

Customer table detail

Oracle Cross Join 2

Supplier table detail

Oracle Cross Join 3

Execute this query

Output

Oracle Cross Join 4



Latest Courses