SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


join on 1=1


join on 1=1

Author
Message
Dev
Dev
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8576 Visits: 1602
It's basically doing a cross join. Maybe the author didn't know about that option.


I haven't seen any instance when people use 1=1 by mistake. It's deliberate CROSS JOIN (just to skip code review tools / team leads ;-) )
Dev
Dev
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8576 Visits: 1602
sqlfriends (11/9/2011)
so if I change the join to cross join and take off 1=1, it will be the same, correct?

But I read somewhere if a cross join have a where clause, it is the same as inner join,

is it true for this case?

Thanks


You can produce CROSS join with any of the following:

select a.*, b.*
from a,b



select a.*,b.*
from a CROSS JOIN b



select a.*,b.*
from a INNER JOIN b
on 1=1 -- fake condition to satisfy INNER JOIN syntax.



The results would be same until you add any filters.
Ninja's_RGR'us
Ninja's_RGR'us
SSC Guru
SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)

Group: General Forum Members
Points: 65045 Visits: 9671
Dev @ +91 973 913 6683 (11/10/2011)
It's basically doing a cross join. Maybe the author didn't know about that option.


I haven't seen any instance when people use 1=1 by mistake. It's deliberate CROSS JOIN (just to skip code review tools / team leads ;-) )



That 1 would actually have been stopped by my review, not the cross join.


Reviews are reviews, no matter what you put in the code.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search