Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Cross joins

The derived table of a cross join is the Cartesian product of the tables involved. Each record in the table to the left of the CROSS operator is linked to each record in the table to the right of the CROSS operator.


Example

Form the Cartesian product of the CUSTOMERS and ORDERS tables:

SELECT *

or

SELECT *

FROM customers, orders


FROM customers CROSS JOIN orders


Table CUSTOMERS

cust_
num

company

...

100

Siemens AG


101

Login GmbH


102

JIKO GmbH


...

...


106

Foreign Ltd.


107

Externa & Co KG



Table ORDER

order_

num

cust_

num

...

200

102


210

106


211

106


...

...


300

101


305

105



Derived table

cust_
num

company

...

order_
num

cust_
num

...

100

Siemens AG


200

102


101

Login GmbH


200

102


102

JIKO GmbH


200

102


...

...


...

...


106

Foreign Ltd.


200

102


107

Externa & Co KG


200

102


100

Siemens AG


210

106


101

Login GmbH


210

106


102

JIKO GmbH


210

106


...

...


...

...


106

Foreign Ltd.


210

106


107

Externa & Co KG


210

106


...

...


...

...


100

Siemens AG


305

105


101

Login GmbH


305

105


102

JIKO GmbH


305

105


...

...


...

...


106

Foreign Ltd.


305

105


107

Externa & Co KG


305

105


Cartesian product of the CUSTOMERS and ORDERS tables