简体   繁体   English

mysql错误:#1052-from子句中的列“ id”不明确

[英]mysql error: #1052 - Column 'id' in from clause is ambiguous

I need join twice for same table - age so I can order by one field of age, how come is it? 我需要在同一张桌子上加入两次-年龄,所以我可以按一个年龄段排序,结果如何?

mysql error: #1052 - Column 'id' in from clause is ambiguous mysql错误:#1052-from子句中的列“ id”不明确

select * from `students` `s` JOIN `age` `a` on `s`.`SN`=`a`.`SN` JOIN (SELECT `s`.`id` FROM `students` `s` JOIN `age` `a` on `s`.`SN`=`a`.`SN` WHERE 1 order by `a`.`age` asc limit 0,2) p using(id) order by `a`.`age` asc

The id is actually ambiguous , explicitly specify the table name, replace: id实际上是模棱两可的 ,显式指定表名,替换为:

using(id)

with: 有:

using(p.id)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL错误#1052 from子句中的列不明确 - MySQL Error #1052 Column in from clause is ambiguous 错误 1052 (23000):where 子句中的列“course_id”不明确 - ERROR 1052 (23000): Column 'course_id' in where clause is ambiguous MySQL错误:冲突:1052 where子句不明确的列'created_at' - Mysql error: violation: 1052 Column 'created_at' in where clause is ambiguous' 完整性约束违规:1052 where子句中的列'id'不明确 - Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel 6 错误:SQLSTATE[23000]:违反完整性约束:1052 where 子句中的列“id_perusahaan”不明确 - Laravel 6 Error : SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_perusahaan' in where clause is ambiguous 错误代码:1052。where子句中的列“ datetime”不明确 - Error Code: 1052. Column 'datetime' in where clause is ambiguous 错误 1052:where 子句中的列“metric_name”不明确 - Error 1052: Column 'metric_name' in where clause is ambiguous 创建视图,错误代码:1052。字段中的“ id”列不明确 - Creating a view, Error Code: 1052. Column “id” in field is ambiguous 错误代码:1052字段列表中的“admin_id”列不明确 - Error Code: 1052 Column 'admin_id' in field list is ambiguous 错误代码:1052。IN/ALL/ANY 子查询中的列 'id' 不明确 - Error Code: 1052. Column 'id' in IN/ALL/ANY subquery is ambiguous
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM