where子句中的列''是不明确的mysql中的错误

Man*_*ano 0 mysql sql asp.net

SELECT tbl_user.userid,
       tbl_user.firstname,
       tbl_user.lastname,
       tbl_user.email,
       tbl_user.created,
       tbl_user.createdby,
       tbl_organisation.organisationname
FROM   tbl_user
       INNER JOIN tbl_organisation
         ON tbl_user.organisationid = tbl_organisation.organisationid
WHERE  organisationid = @OrganisationID;  
Run Code Online (Sandbox Code Playgroud)

我正在使用此语句来执行数据绑定.我在这里收到错误.

where子句中的"OrganisationID"列不明确

我应该怎么做才能将tbl_user中的OrganisationID命名为与tbl_organisation相同.OrganisationID是来自tbl_Organisation的外键

bfa*_*tto 5

由于在两个不同的表上有两个具有相同名称的列(并且这不是问题,甚至在许多情况下都建议使用它),因此必须通知MySQL要过滤哪个.

在列名称之前添加表名(或别名,如果您使用表别名).在你的情况下,要么

WHERE tbl_user.OrganisationID
Run Code Online (Sandbox Code Playgroud)

要么

WHERE tbl_Organisation.OrganisationID
Run Code Online (Sandbox Code Playgroud)

应该管用.