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 trialRanvir Sahota
9,844 PointsColumn is specified but still ambiguous
I have resolved the issue however I fail to understand why the column was ambiguous. The problem with the code was I repeating the table that I was using for INNER JOIN in the FROM section. But why should this cause ModelName to be ambiguous.
SELECT Model.ModelName AS 'Model Name', Car.VIN, Car.StickerPrice AS 'Sticker Price' FROM Car, Model INNER JOIN Model ON Car.ModelID=Model.ModelID
1 Answer
Steven Parker
231,271 PointsIt becomes ambiguous when you have two of the same thing.
When you include the table the second time, you now have two columns with exactly the same name, so the database engine can't determine which one of the two you are asking for in your SELECT
clause.
To resolve such an ambiguity, you would need to be able to distinguish the columns from each other. A table alias would be useful in such a case.
Ranvir Sahota
9,844 PointsRanvir Sahota
9,844 PointsThanks for that and sorry for not making question clear the first time