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

Robbie Thomas
Robbie Thomas
31,093 Points

Querying Relational Databases

For challenge 1 of 5, I have the following code

SELECT * FROM model INNER JOIN car ON model.ModelName, car.VIN, car.StickerPrice;

It's not working. Quite confused on this one.

Hi Robbie,

A couple of separate things to consider.

1) The challenge asks you to display only Model Name, VIN, and Sticker Price, but your use of the asterisk will retrieve all columns. I see the columns are placed at the end of the query, they need to be moved up to replace the asterisk, and you don't need the table names in this case.

2) You haven't completed the join entirely. After the ON, you'll need to type in the columns you're going to join on using a foreign key. For example, there's a column in each table for the ModelID, so after INNER JOIN Car ON, you could enter Model.ModelID = Car.ModelID;

I'll put the answer that I found down this page a little bit in case you want to try to edit it without seeing the answer. Scroll to see it:

*

*

*

*

*

*

*

SELECT ModelName, VIN, StickerPrice FROM Model INNER JOIN Car ON Model.ModelID = Car.ModelID;

1 Answer

Robbie Thomas
Robbie Thomas
31,093 Points

Thank you for that. Very helpful on better understanding the INNER JOIN.

You're welcome; happy to help.