From the course: Practice It: SQL Joins

Understanding cross joins - SQL Tutorial

From the course: Practice It: SQL Joins

Understanding cross joins

- [Instructor] The last join we're going to review is the cross join. This is also known as a Cartesian product and this is one where you have to be very careful because in this case, relationships don't matter at all. Imagine I have a hundred records in table A and 200 records in table B. If I were to do a cross join on these two tables for record one in table A I would repeat and join to all 200 records in table B. I would repeat this for all 100 records in table A, resulting in a data set with 20,000 rows. You can imagine this is not a very good idea for large tables as it could bring your database to a crawl. Cross joins are helpful for bringing together combinations from two different tables. You'll definitely want to stick to smaller tables when performing cross joins and we'll look at some examples in practice. The syntax looks like this. You can select all from table A, join B or select all from A cross join B.

Contents