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

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

Please help querying Relation Database challenge 4/5

I getting a bummer

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

Can i please do it tomorrow its 23.00 here in Sweden must go and sleep thanx for quick answer sorry i will try the challenge again

12 Answers

Kevin Gates
Kevin Gates
15,053 Points

The correct answer for challenge 4/5 is this:

SELECT m.ModelName, c.VIN
FROM Model AS m
   LEFT OUTER JOIN Car AS c
      ON m.ModelID = c.ModelID;

So, Jacob Iraheta , on yours, it's important that the first table listed (the one after the FROM keyword) is Model. By using a LEFT OUTER JOIN, you are saying "When I compare TABLE 1 (Model) to TABLE 2 (Car), then IF the TABLE 2 does not have a value, return null instead."

This means for this challenge that a Model (say "Civic") hasn't sold yet, therefore it's not an entry on the car table, even though that model technically exists.

Joel McCracken Jr
Joel McCracken Jr
3,142 Points

This is what fixed it for me

Select Model.ModelName, Car.VIN from Model left outer join Car on Car.Modelid = Model.ModelID left outer join Make on Model.MakeID = Make.MakeID;

Nice! You're doing great!

Shea Matthew Kennisher
Shea Matthew Kennisher
2,574 Points

Why does this even work if there is no Make table in this question?

But why? Where does the Make come into this?

Select Model.ModelName, Car.VIN from Model left outer join Car on Car.Modelid = Model.ModelID left outer join Make on Model.MakeID = Make.MakeID;

This code works but I am wondering if anyone can explain why it works and where does the Make come into this

ALBERT QERIMI
ALBERT QERIMI
49,872 Points

Andrew Chalkley i think is a bug in database Attach my code to this post. checkbox .

asked two questions lately but code didn't show on question Thanks

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

Select Make.MakeName, Model.ModelName, Car.VIN,Car.StickerPrice from Car left outer join Model on Car.ModelID = Model.ModelID left outer join Make on Model.MakeID = Make.MakeID

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

Please help querying Relation Database challenge 4/5

Bummer Your query didn't select the ModelName and VIN correctly! please explain to me what is wrong i asked my teacher but he did not understand the quiz

Select Model.ModelName, Car.VIN,Car.StickerPrice from Model left outer join Car on Car.Modelid = Model.ModelID left join Make on Model.MakeID = Make.MakeID;

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

Looks like this left join Make on Model.MakeID = Make.MakeID; isn't needed on 4 / 5.

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

here are the quiz I n a car database there is a Model table with columns, ModelID, MakeID and ModelName and a Car table with columns, CarID, ModelID, VIN, ModelYear and StickerPrice. Show all Model names from the Model table along with VIN from the Car table. Make sure models that aren’t in the Car table still show in the results!

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

select Model, ModelID, VIN,ModelYEAR, stickerprice from Model left outer join Car

Alain De La Cuadra
Alain De La Cuadra
21,890 Points

Select Model.ModelName, Car.VIN,Car.StickerPrice from Model left outer join Car on Car.Modelid = Model.ModelID left join Make on Model.MakeID = Make.MakeID; BUMMER please help

Select Model.ModelName, Car.VIN,Car.StickerPrice from Car inner join Model on Car.ModelID = Model.ModelID inner join Make on Model.MakeID = Make.MakeID

Jacob Iraheta
Jacob Iraheta
2,182 Points

anyone have an answer to this and why the below code works??? maybe the question written incorrectly?

Select Model.ModelName, Car.VIN from Model left outer join Car on Car.Modelid = Model.ModelID left outer join Make on Model.MakeID = Make.MakeID;

Anyone that used Make table has either just copied from someone else in the forum or has a completely different Challenge 4/5 than me and some others. Please explain why or how you got your answer then.

SELECT ModelName, VIN FROM Model LEFT OUTER JOIN Car ON Model.ModelID = Car.ModelID 
WHERE Car.ModelID IS NULL;

Yes this should work, and I tried different ways to select the columns and get this error:

Bummer: Your query didn't select the ModelName and VIN correctly!

Only thing I can think of is that you make another table to put both together

Kevin Gates
Kevin Gates
15,053 Points

See my answer posted above on January 7.