A CROSS JOIN
performs a join between two tables that does not use an explicit join clause and results in the Cartesian product of two tables. A Cartesian product means each row of one table is combined with each row of the second table in the join. For example, if TABLEA
has 20 rows and TABLEB
has 20 rows, the result would be 20*20 = 400
output rows.
Example:
SELECT *
FROM TABLEA CROSS JOIN TABLEB;
This can also be written as:
SELECT *
FROM TABLEA, TABLEB;
Here's an example of cross join in SQL between two tables:
Sample Table: TABLEA
+-------+---------+
| VALUE | NAME |
+-------+---------+
| 1 | ONE |
| 2 | TWO |
+-------+---------+
Sample Table: TABLEB
+-------+--------+
| VALUE | NAME |
+-------+--------+
| 3 | THREE |
| 4 | FOUR |
+-------+--------+
Now, If you execute the query:
SELECT *
FROM TABLEA CROSS JOIN TABLEB;
Output:
+-------+--------+-------+--------+
| VALUE | NAME | VALUE | NAME |
+-------+--------+-------+--------+
| 1 | ONE | 3 | THREE |
| 1 | ONE | 4 | FOUR |
| 2 | TWO | 3 | THREE |
| 2 | TWO | 4 | FOUR |
+-------+--------+-------+--------+
This is how cross joining happens between two tables:
More about Cross Join: Oracle documentation