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

INNER JOIN 3 Table and Multiple Columns.

There are 3 tables and Multiple Columns i am not sure how to use INNER JOIN twice after FROM keyword.

2 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

Here's a pseudo-code example:

SELECT
T1.field1
T2.field2
T3.field3
FROM T1
INNER JOIN T2 ON (T1.someId = T2.someId)
INNER JOIN T3 ON (T2.someOtherId = T3.someOtherId) 
-- The second JOIN could also match T1.someId if the same column is in T3

Thanks! Got it.