简体   繁体   中英

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

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:

using(id)

with:

using(p.id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM