Databases Querying Relational Databases Joining Table Data with SQL JOIN Queries

Bennett Lappen
Bennett Lappen
12,035 Points

How do I know which table to make 'Inner'?

This example (like others) provides two tables. In this case, Model and Car. How do I know whether to apply INNER JOIN Car OR INNER JOIN MODEL. The order of of the rest of the formula changes depending on which item I set to INNER. How do I select between the tables?

1 Answer

Pedro Cabral
Pedro Cabral
22,688 Points

I'm not 100% sure if I understood the problem correctly. You want to know if you should do foo INNER JOIN bar or bar INNER JOIN foo? If so, it doesn't really matter because the result is an intersection of both tables based on the condition set on the ON. What do you mean by "the rest of the formula changes depending on which item I set to INNER"? Regarding selecting between tables you do it by writing tablename.columnname or tablenamealias.columnname