Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Gregory Ledger
Gregory Ledger
6,116 Points

Why is it a "good practice" to alias the tables, and add them as prefixes in the SELECT and JOIN parts of the statement?

So, the video says that this is a good practice, but doesn't explain why it is better.

Please advise.

This is about Querying Relational Databases INNER JOIN video

1 Answer

Steven Parker
Steven Parker
231,007 Points

Prefixing columns with table identifiers prevents any ambiguity due to similar column names (either now or if the tables should be expanded in the future), and using aliases instead of the full table names saves time and makes the code more compact and readable.

Gregory Ledger
Gregory Ledger
6,116 Points

Too bad all the tasks following that exercise don't demand prefixes as part of the answer