473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

importance of order in the ON statement

Hello All,

I have had a question come up and was wondering if anyone knew the answer. Given the following query:

Select * From Table1 Left Outer Join Table2 On Table1.Id = Table2.Id

Is there any difference if the On statement was switched? Such as:

Select * From Table1 Left Outer Join Table2 On Table2.Id = Table1.Id

Thanks
Jan 21 '08 #1
4 1154
priyamv
17
I think there is no difference between the two statements both will give the same results.But if you change the names of the tables after from statement then the result will change
Jan 21 '08 #2
debasisdas
8,127 Expert 4TB
Since it is Left Outer Join the position of the tables is very important.

A LEFT OUTER JOIN is one of the JOIN operations that allow you to specify a join clause. It preserves the unmatched rows from the first (left) table, joining them with a NULL row in the shape of the second (right) table.
Jan 21 '08 #3
Since it is Left Outer Join the position of the tables is very important.

A LEFT OUTER JOIN is one of the JOIN operations that allow you to specify a join clause. It preserves the unmatched rows from the first (left) table, joining them with a NULL row in the shape of the second (right) table.
So are you saying that the position of the tables are important specifically in the On statement?

table1.id = table2.id as opposed to table2.id = table1.id.
Jan 21 '08 #4
Jim Doherty
897 Expert 512MB
So are you saying that the position of the tables are important specifically in the On statement?

table1.id = table2.id as opposed to table2.id = table1.id.
If you look at the execution plan for the specific join the ON element with your table1.id=table2.id you will see that their is no distinction on execution in terms of which way round it is presented. In other words it makes no difference a column is being compared with a column. The LEFT join preserve is of course on table1 as that is what you are selecting from.

Jim :)
Jan 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rick Snagglehimer | last post by:
I keep getting an error from the following SP snippet "Line 11: Incorrect syntax near 'BY'." It runs fine without the ORDER BY clause. >>>>>>>>>>>>>>> WHERE .clientID = .userID
3
by: Mike D | last post by:
The code below gives an error. Object doesn't support this property or method: 'myMail.Importance' How do I set importance on an email? Everywhere I have looked it looks like my syntax is right...
3
by: Jason Kistler | last post by:
I am having some serious issues trying to set the "importance" of an ASP email. I am using the CDO.Message object. Here is the code: <% Dim recipients recipients = Request.Form("Jason") &...
1
by: Jeff Blee | last post by:
I hope someone can help me get this graph outputing in proper order. After help from Tom, I got a graph to display output from the previous 12 months and include the average of that output all in...
16
by: mdh | last post by:
May I ask the group the following: (Again, alas , from K&R) This is part of a function: while ( ( array1 = array2 ) != '\0' ); /* etc etc */ Is this the order that this is evaluated? ...
3
by: Beowulf | last post by:
I was just messing around with some ad hoc views and table returning UDFs today so I could look at and print out data from a small table and noticed something strange. If I stick my select...
6
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on...
1
by: Whyatt | last post by:
Hi all, I'm trying to create a message using SMTP Mail through Python with a message Importance of either 0 (Low) or 2 (High). If I do outer.Add_header('Importance', '0') it is ignored. If...
3
by: ylekot88 | last post by:
Hi I am a student, I am trying to figure this out. I am trying to run a select statement that is asking for customer#, date, and total price of each order. ensure results are in chronological...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.