ERROR WHILE JOIN TABLE IN SQL

jayprakash sharma

Total Post:117

Points:821
Posted by  jayprakash sharma
 884  View(s)
Ratings:
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?

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Error while join table in SQL

    Hi Jay, 

    try this:

    SELECT CarReserve.ID

        FROM CarReserve

        INNER JOIN aspnet_Users ON CarReserve.UserName = aspnet_Users.UserName

        WHERE aspnet_Users.UserName = @UserName

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!