mysql报错 unknown column ’a.plat’ in ON clause
问题描述
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: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;
相关文章:
1. docker绑定了nginx端口 外部访问不到2. mac连接阿里云docker集群,已经卡了2天了,求问?3. python - 使用pandas的resample报错4. angular.js - angular内容过长展开收起效果5. docker内创建jenkins访问另一个容器下的服务器问题6. gulp-ruby-sass编译出来的文件有错7. javascript - 使用vue做个抽奖问题8. docker start -a dockername 老是卡住,什么情况?9. node.js - windows下安装webpack时出现路径问题如何解决?10. javascript - webpack异步加载js问题

网公网安备