By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

Optimal SQL

P: n/a
Please excuse what is probably a no-brainer, but here goes.

Is there any difference, in terms of performance or any other pertinent
factor, between:

SELECT * FROM tblCustomers INNER JOIN tblCustomerOrders ON
tblCustomers.fldCustomerID = tblCustomerOrders.fldCustomerID

and

SELECT * FROM tblCustomers, tblCustomerOrders WHERE
tblCustomers.fldCustomerID = tblCustomerOrders.fldCustomerID

I note that if I type the latter into the SQL pane in a Data window,
SQL Server replaces it with the former.

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Should give the same query plan.

Nigel Rivett
www.nigelrivett.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #2

P: n/a
If you examine the execution plans in Query Analyzer you will find the two
statements are identical. For INNER JOINs either syntax is legal and which
you use really comes down to readability and personal preference.
I note that if I type the latter into the SQL pane in a Data window,
SQL Server replaces it with the former.


One reason to avoid GUI query tools is that they tend to mess with the
formatting and syntax of your code. My advice is to use a proper query
editor, like Query Analyzer. In the long run you'll find you can write
better code much quicker that way.

--
David Portas
SQL Server MVP
--
Jul 23 '05 #3

P: n/a
David Portas wrote:
If you examine the execution plans in Query Analyzer you will find the two statements are identical. For INNER JOINs either syntax is legal and which you use really comes down to readability and personal preference.
I note that if I type the latter into the SQL pane in a Data window, SQL Server replaces it with the former.
One reason to avoid GUI query tools is that they tend to mess with

the formatting and syntax of your code. My advice is to use a proper query editor, like Query Analyzer. In the long run you'll find you can write better code much quicker that way.

Thanks to you and Nigel. I agree with your distress at the way the GUI
tool in SQL Server messes with code - I like to have things laid out
just so, and it's no business of SQL Server to do it's nanny thing.
But that's Microsoft for you, the company that brought us Office
Assistant.

Unfortunately, for very involved outer joins with multiple tables, I'm
just not expert enough to craft the thing in QA, or rather I like to
see a graphical representation of the table relations. But I suppose I
could write it in QA, then paste it into a Data pane and see what the
GUI made of it.

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk
--
We are what we repeatedly do. Excellence, then, is not an act, but a
habit - Aristotle

Those heights by great men reached and kept
Were not obtained by sudden flight,
But they, while their companions slept
Were toiling upward in the night
- Longfellow

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.