From the course: Querying Microsoft SQL Server 2022

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Cross joins

Cross joins

- [Instructor] Most of the time you want to join data tables based on common values to find the information that relates together. But you can also join data tables that have no relationship to each other in something called a cross join. Cross joins are literally the cross product that you get from combining every record in one table with every record from the other. To see how this works, we'll take a look at two SELECT queries. One that pulls the Name column from the HumanResources.Department table and the other one that pulls the Name column from the Person.AddressType table. Let me highlight both of these and press Execute to see the results. At the top, we have these 16 names of our departments. Then below that we have the six names of our AddressTypes. A cross product would multiply the tables together. So you'd have Document Control and Archive, Document Control and Billing, Document Control and Home, and so on.…

Contents