Using the table name in the identification column is a little redundant, but I find it useful and more visual, especially when executing foreign keys. For example, what seems better:
SELECT P.PersonID, P.FullName, W.WidgetID, W.WidgetName FROM Widgets W JOIN PersonWidgets PW ON W.WidgetsID = PW.WidgetsID JOIN Person P ON P.PersonID = PW.PersonID
OR
SELECT P.ID as PersonID, P.FullName, W.ID as WidgetID, W.WidgetName FROM Widgets W JOIN PersonWidgets PW ON W.ID = PW.WidgetsID JOIN Person P ON P.ID = PW.PersonID
The first query is more explicit and leads to less random joins. It also eliminates the need to use aliases in your SELECT list.
Garrett vlieger
source share