Skip to the content.

When you have a complex operation involving multiple tables, it can be hard to track which table is which - and where each column is coming from. Using table and column aliases makes this much clearer.

Add aliases to all tables / expressions, and use those aliases for all column access.

Bad:

select Id, Name, Address
from Users
inner join Addresses
  on UserId = Id

Good:

select u.Id, u.Name, a.Address
from Users u
inner join Addresses a
  on a.UserId = u.Id