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 Querying Relational Databases Joining Table Data with SQL Inner Joins

Inner join

Hello,

When you join 2 tables like the below, after ON do you always have to the name of a table dot the primary key equal to the name of the other table dot foreign key?

SELECT * FROM make INNER JOIN Model ON make.MakeID = Model.MakeID ;

2 Answers

The only time I think its acceptable but NOT "Good Practice" is if the column name was unique, other wise putting the dot after the table specifies which column you want to join.

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

I don't quite understand the question ...

Yes I think you always have to write condition on which you join tables.

How do you think SQL can infer which columns are equal ?

SQL cannot just know which columns to compare ...