Microsoft KB Archive/45493

= PRB: Using a Self-Join to Produce a Cartesian Product =

Article ID: 45493

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft SQL Server 4.21a Standard Edition

-



This article was previously published under Q45493



SYMPTOMS
In attempting to produce the Cartesian product of a table with itself, a self-join without a WHERE clause produces only the table itself.



CAUSE
A 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



WORKAROUND
The following does produce a Cartesian product:

  select x.c1,y.c1 from t1 x, t2 y

This is the intended operation of SQL Server.

Additional query words: Transact-SQL Windows NT

Keywords: kbprogramming KB45493

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.