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 trialMuhammad Sameed
806 PointsAmbiguous column name error.
hi, I am trying the following query but I get ambiguous column name error. Please advise how can I fix it?
SELECT * FROM SUBJECTS JOIN SUBJECTS ON SUBJECTS.NAME = CLASSES.SUBJECT_ID;
1 Answer
cgeorge
5,493 PointsHello, bummer you had to wait so long for a response. Better late than never.
An ambiguous column name error usually means that you have a column name that appears in two tables so you need to clarify or that your column name is already defined within sql.
In your code you appear to be joining a table Subjects to itself (FROM SUBJECTS JOIN SUBJECTS ). I think you meant to join subjects to classes. Also, the column you join the tables on have to have the same values. Subject_ID in the Classes table is a number. The Name column in the Subject table is text. Yo need to find the column that classes and subject table have in common and join on that.
GOOD LUCK!