Reputation: 2886
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.
Upvotes: 0
Views: 73
Reputation: 325
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.
Upvotes: 0
Reputation: 60502
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
Upvotes: 1
Reputation: 872
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
Upvotes: 1