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

Alexander Nikiforov
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,139 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 ...

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.