[Err] 1052 - Column ‘roleId‘ in where clause is ambiguous

网友投稿 592 2022-09-03

[Err] 1052 - Column ‘roleId‘ in where clause is ambiguous

[Err] 1052 - Column ‘roleId‘ in where clause is ambiguous

1、先看错误的sql语句:

select a.authName from roles as r,authority as a,role_ah as ra where ra.roleId=r.roleId and ra.ahId=a.ahId and roleId='R002'

2、再看正确的sql语句:

select a.authName from roles as r,authority as a,role_ah as ra where ra.roleId=r.roleId and ra.ahId=a.ahId and r.roleId='R002'

[Err] 1052 - Column ‘roleId’ in where clause is ambiguous

这句话的意思是:[Err]1052-where子句中的“roleId”列不明确

多个表中都有相同的属性列(我这里是角色表、权限表、角色权限联合表。角色权限联合表中包含着角色表和权限表中的主键)。在查询时,没有指定哪个表的属性列。

总结:当遇到多表查询、并且查询条件的属性列存在多个表时、需要显示定义具体表的属性列。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:39条技巧优化PHP代码,来复习总结下吧(php代码优化包括哪些方面)
下一篇:PHP生成短链接的实例汇总与分享(php长连接)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~