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

How is it possible to select the column that doesn't exist in the table it is selected from?

I'm referring to "Quering the database course - Inner joints". Andrew selected the ModelName column FROM the Make table, but ModelName column exists only in Model table? Superconfusing.

2 Answers

Hi Marcin!

Keep in mind that when you are joining tables, you will have access to columns in BOTH tables in your query.

I didn't go back and look at the course, but usually, the SELECT statement specifies the related table and column, like this, for example:

SELECT table1.column3, table2.column7
FROM table1
INNER JOIN ON table1.id = table2.id;

(Or something like that...)

More info:

https://www.w3schools.com/sql/sql_join_inner.asp

And yes, for the record, I agree/think SQL JOIN syntax is SUPERCONFUSING and written by a serial sadist!?! LOL

I hope that helps.

Stay safe and happy coding!

Many thanks, I thought that selecting has to occur first (before joining can happen).