Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Continuation of Message #1594531 - Use of WHERE
Message
From
23/02/2014 14:53:05
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01594922
Message ID:
01595006
Views:
37
>>>There is one important problem in this code sample - the OrderDate is not prefixed with the alias. Without that we would need to check which table this column belongs to.
>>>My rule of thumb - prefix every column with an alias name when the query involves more than 1 table.
>>
>>I don't disagree with the rule of thumb, especially with several tables. But with 2 tables (a business entity master and a child table of orders), any question about the lineage of OrderDate is more likely a problem with the person in the chair. :)
>>
>
>The rule is the rule - and I always follow it.

I realize words can have multiple meanings, but an example of a rule is referencing a column that belongs to multiple tables in a query - in that situation, you must specify the table alias, or you'll get an ambiguity error.

What you're describing is a practice. (And certainly a good one). If you always follow it, that's great. Not everyone does (even Microsoft generated SQL queries don't always do it when a column is unique to a table).

I'll say this - I see some people (not you) who use meaningless one letter table alias designations. This one is royally stupid.

SELECT a.Column1, a.Column2, b.Column3, c.Column4
from Table1 A
join Table2 B
join Table3 C
Previous
Reply
Map
View

Click here to load this message in the networking platform