Kegune Kegune - 3 years ago 196
SQL Question

I do not understand why I am getting the error message Ambiguous column name 'FirstName' when compiling

SELECT FirstName
FROM Adjuncts INNER JOIN Faculty
ON Adjuncts.FirstName = Faculty.FirstName


Above is my Microsoft SQL server 2012 code. I am trying to join two tables together (Adjuncts, and Faculty) and share their FirstName, and LastName columns. I tried to just do one (FirstName) to see if I could make it work, and could not. I was receiving the following error message:

"Msg 209, Level 16, State 1, Line 1 Ambiguous column name 'FirstName'. "

Is anyone able to tell me how to properly join the two tables together? And how to show ONLY the 'FirstName' & 'LastName' columns which are defined in each of the tables WITHOUT overlapping the 'FirstName' & 'LastName' columns and having them twice. Any feedback would be appreciated!

Answer Source

Both tables in your query (Adjuncts and Faculty) have a FirstName column, so you have to fully qualify it. E.g.:

SELECT     Adjuncts.FirstName
-- Here ---^
FROM       Adjuncts
INNER JOIN Faculty ON Adjuncts.FirstName = Faculty.FirstName  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download