MOCKSTACKS
EN
Questions And Answers

More Tutorials









Oracle JOINS

CROSS JOIN


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 |
+-------+--------+-------+--------+



Conclusion

In this page (written and validated by ) you learned about Oracle JOINS . What's Next? If you are interested in completing Oracle tutorial, your next topic will be learning about: Oracle Handling NULL values.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.