Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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