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. css3 - 微信前端页面遇到的transition过渡动画的bug2. 网页爬虫 - 关于Python的编码与解码问题3. javascript - vue 父子组件传递数据4. html5上的ICON一般去哪里找?5. javascript - Storage中removeItem在什么情况下使用6. css - input间的间距和文字上下居中7. MYSQL 根据两个字段值查询 但两个值的位置可能是互换的,这个怎么查?8. selenium-selenium-webdriver - python 将当前目录加入到 环境变量9. css - 有没有什么办法用背景色把部分border给遮挡呢?10. css3 - 微信小程序如何把radio改成2个选择按钮的样式

网公网安备