Cross Join vs. Selecting from multiple tables

I am working through the REBU project here:

https://www.codecademy.com/paths/data-science/tracks/sql-intermediate/modules/dspath-sql-multiple-tables/projects/querying-tables

On step three, the instructions call for a CROSS JOIN on the riders and cars tables. However, the query in the hidden hint gets the result set by SELECT FROM the riders and cars tables.

Do these two approaches essentially accomplish the same thing since they are not matching on a key? And if so, is there any advantage of using one approach over the other?

These are exactly the same operation, however CROSS JOIN wasn’t always there before. a CROSS JOIN returns the product of the two tables, hence why you get 16 rows when you CROSS JOIN the two tables, both with 4 rows. By writing it as

SELECT *
FROM riders, cars;

You are doing the same thing, it’s just there’s now a join operation for it, so it’s usually recommended to use that.

1 Like

Okay, this is good to know. I imagine that can make quite a difference in processing speed and efficiency once the tables become larger.

Thank you.