Heim > Fragen und Antworten > Hauptteil
select truncate(a.lat, 2) as plat, truncate(a.lng, 2) as plng, temp.latt, temp.lngt from user_post as a inner join
(select truncate(user_post.lat, 2) as latt, truncate(user_post.lng, 2) as lngt from user_post group by latt, lngt having count(latt) >= 4 and count(lngt)>= 4) as temp
on (a.plat = temp.latt and a.plng = temp.lngt);
Warum wird ein solcher Fehler gemeldetunknown column 'a.plat' in ON clause
?
phpcn_u15822017-06-30 09:56:48
a别名指向的是表user_post,从你的语句中来看,user_post表中有lat字段,没有plat字段。
所以on条件中的a.plat是不对的。
加个括号试下:
select a.plat, a.plng, temp.latt, temp.lngt
from
(select truncate(lat, 2) as plat, truncate(lng, 2) as plng from user_post) as a
inner join
(select truncate(lat, 2) as latt, truncate(lng, 2) as lngt from user_post group by latt, lngt having count(latt) >= 4 and count(lngt)>= 4) as temp
on a.plat = temp.latt and a.plng = temp.lngt;