SQL JOIN CROSS JOIN

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Cross join does a Cartesian product of the two members, 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.

Using example database

SELECT d.Name, e.FName
FROM   Departments d
CROSS JOIN Employees e;

Which returns:

d.Namee.FName
HRJames
HRJohn
HRMichael
HRJohnathon
SalesJames
SalesJohn
SalesMichael
SalesJohnathon
TechJames
TechJohn
TechMichael
TechJohnathon

It is recommended to write an explicit CROSS JOIN if you want to do a cartesian join, to highlight that this is what you want.



Got any SQL Question?