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;
我正在使用此语句进行数据绑定(bind)。我在这里遇到错误。
where 子句中的“OrganisationID”列不明确
tbl_user 中的OrganisationID 与tbl_organisation 同名是错误的怎么办? OrganisationID 是来自 tbl_Organisation 的外键
最佳答案
因为在两个不同的表上有两个同名的列(这不是问题,在许多情况下甚至推荐这样做),您必须通知 MySQL 您要根据哪一个进行过滤。
在列名前添加表名(或别名,如果您使用表别名)。在你的情况下,要么
WHERE tbl_user.OrganisationID
或
WHERE tbl_Organisation.OrganisationID
应该可以。
关于asp.net - where 子句中的列 ' ' 不明确 mysql 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7517382/