Databases Querying Relational Databases Joining Table Data with SQL JOIN Queries

Robbie Thomas
Robbie Thomas
31,092 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,092 Points

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

You're welcome; happy to help.