If you have a “grid” that you want to completely fill out, for example, the size and color of information for a particular piece of clothing:
select size, color from sizes CROSS JOIN colors
Perhaps you need a table containing a row for every minute of the day, and you want to use it to verify that the procedure was running every minute, so you can cross three tables:
select hour, minute from hours CROSS JOIN minutes
Or you have a set of standard report specifications that you want to apply to each month of the year:
select specId, month from reports CROSS JOIN months
The problem with preserving these ideas is that in most cases you do not need a complete product, especially with regard to clothing. You can add MINUS logic to the query to remove certain combinations that you don’t wear, but it may be easier for you to fill out the table in some other way than to use the Cartesian product.
Alternatively, you can try cross-joining tables that have perhaps more rows than you thought, or maybe your WHERE was partially or completely missing. In this case, your database administrator will immediately notify you of the omission. Usually he or she will not be happy.
Dave DuPlantis Oct. 20 '08 at 20:20 2008-10-20 20:20
source share