O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CROSS JOINs

A CROSS JOIN generates a Cartesian product of the tables specified in the JOIN operation. In other words, the result set of a CROSS JOIN operation contains every possible combination of rows of the tables involved in the query. In particular, if there are n rows in the first table and m rows in the second table, the result set will have n*m rows.

These are the two possible ways to specify a CROSS JOIN operation:

SELECT * FROM Table1, Table2
SELECT * FROM Table1 CROSS JOIN Table2

Listing 5.18 shows an example that generates a Cartesian product using CROSS JOIN. The tables involved in the CROSS JOIN have 7 and 8 rows, respectively, and the result set has 56 rows (7*8).

Code Listing 5.18. Using CROSS JOIN to Generate a Cartesian Product ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required