Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

join on 1=1 Expand / Collapse
Author
Message
Posted Thursday, November 10, 2011 12:29 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 6:53 PM
Points: 1,932, Visits: 1,589
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

Devendra Shirbad | BIG Data Architect / DBA | Ex-Microsoft CSS (SQL 3T)
*** Open Network for Database Professionals ***

LinkedIn: http://www.linkedin.com/in/devendrashirbad
Post #1203306
Posted Thursday, November 10, 2011 12:35 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 6:53 PM
Points: 1,932, Visits: 1,589
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.


Dev

Devendra Shirbad | BIG Data Architect / DBA | Ex-Microsoft CSS (SQL 3T)
*** Open Network for Database Professionals ***

LinkedIn: http://www.linkedin.com/in/devendrashirbad
Post #1203308
Posted Thursday, November 10, 2011 4:48 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 10:58 PM
Points: 20,594, Visits: 9,627
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.
Post #1203401
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse