Home > DeveloperSection > Forums > Error while join table in SQL
jayprakash sharma
jayprakash sharma

Total Post:117

Points:821
Posted on    August-21-2014 12:43 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 650  View(s)
Rate this:

I have two tables that have relationship with UserName field. Based on UserName column, I want to get ID from CarReserve table. Here is my SQL statement:

SELECT CarReserve.ID

FROM CarReserve

 INNER JOIN aspnet_Users ON CarReserve.UserName = aspnet_Users.UserName

WHERE UserName = @UserName

Unfortunately, I am getting this warning:

Ambiguous column name "UserName"

Can anyone here tell me what is wrong with my statement?



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-21-2014 1:13 AM

Hi Jay, 
try this:

SELECT CarReserve.ID

    FROM CarReserve

    INNER JOIN aspnet_Users ON CarReserve.UserName = aspnet_Users.UserName

    WHERE aspnet_Users.UserName = @UserName


Don't want to miss updates? Please click the below button!

Follow MindStick