mysql 报错 ON 子句中的未知列 'a.plat'
漂亮男人
漂亮男人 2017-06-30 09:54:48
0
1
1009
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);

为什么会报unknown column 'a.plat' in ON clause 这样的错误?

漂亮男人
漂亮男人

全部回复(1)
phpcn_u1582

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;
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!