PRB: Using a Self-Join to Produce a Cartesian ProductLast reviewed: April 25, 1997Article ID: Q45493 |
The information in this article applies to:
- Microsoft SQL Server version 4.2 for OS/2 - Microsoft SQL Server version 4.2
SYMPTOMSIn attempting to produce the Cartesian product of a table with itself, a self-join without a WHERE clause produces only the table itself.
CAUSEA self-join without a WHERE clause does not produce a Cartesian product unless the two instances of the table are given aliases and the select list includes columns from both aliases. The following does not produce a Cartesian product:
select * from t1,t1 WORKAROUNDThe following does produce a Cartesian product:
select x.c1,y.c1 from t1 x, t2 yThis is the intended operation of SQL Server.
|
Additional query words: Transact-SQL Windows NT
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |