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 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

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