0

What is the necessary condition to have the same result from a JOIN and a Cartesian Product ?

I don't think it is possible, if anyone can clear me will be great, thanks.I've searched but I couldn't an answer to my question.

Marian Pavel
  • 2,726
  • 8
  • 29
  • 65

3 Answers3

1

If you are using SQL Server, the CROSS JOIN join type can achieve the same thing as a cartesian product. It matches every row from the left table to every row in the right. This is illustrated in the following SO question:

What is the difference between Cartesian product and cross join?

And a little MS documentation also: https://technet.microsoft.com/en-us/library/ms190690%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396

Community
  • 1
  • 1
Kris Gruttemeyer
  • 872
  • 7
  • 19
1

All three queries return the same result:

select *
from t1 cross join t2 

select *
from t1,t2 

select *
from t1 join t2 
on 1=1
dnoeth
  • 59,503
  • 4
  • 39
  • 56
0

A cartesian product is equivalent to a join that always evaluates to true. So

 Table1 join Table2 on 1=1 

will give you a cartesian product.

Matze
  • 325
  • 1
  • 12