trainingtrains Logo

91-9990449935

 0120-4256464

PostgreSQL Cross Join

The CROSS JOIN matches every row of the first table with every row of the second table. It is also known as Cartesian product join. If the table1 has "x" columns and table2 has "y" columns then the resultant table will has the (x+y) columns.

Syntax:

See this example:

Let's take a table "EMPLOYEES" having the following data.

Table1: EMPLOYEES

PostgreSQL cross join1

Create another table "DEPARTMENT" having the following data.

Table2: DEPARTMENT

PostgreSQL cross join2

Execute the following query:

Output:

PostgreSQL cross join3