Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimization Questions
Message
From
08/02/2007 10:07:06
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Optimization Questions
Miscellaneous
Thread ID:
01193611
Message ID:
01193611
Views:
52
I have a few optimization questions about SQL queries.

First, what syntax would be preferred to join two tables:
... FROM (Table_1 INNER JOIN Table_2 ON Table_1.Col = Table_2.Col)
INNER JOIN Table_3 ON Table_1.Col = Table_3.Col ...
or
... FROM Table_1, Table_2, Table_3 WHERE Table_1.Col = Table_2.Col AND
Table_1.Col = Table_3.Col ...
Second, is a JOIN or a Subquery usually most efficient:
SELECT Customer.CustomerID, Customer.CustomerName, Status.StatusName
FROM Customer INNER JOIN Status on Customer.Status = Status.StatusID
or
SELECT CustomerID, CustomerName, (SELECT StatusName FROM Status WHERE Status.StatusID = Customer.Status) AS Status
FROM Customer
Very fitting: http://xkcd.com/386/
Next
Reply
Map
View

Click here to load this message in the networking platform