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 gitlab 如何git clone?2. dockerfile - [docker build image失败- npm install]3. 前端 - Jade模板如何控制Label文字位置4. java - List<List<model>>如何更快捷的取里面的model?5. javascript - vue-cli中 用proxyTable实现了跨域,用get访问没有问题,但通过 post传数据就出现了问题6. Java编程里一般怎么管理接口的实现类?7. java - log4j和slf4j 【配置有知道的么】8. [python2]local variable referenced before assignment问题9. java - jdbcTemplate支持复杂对象的映射吗?10. android webview和远程页面交互?
![dockerfile - [docker build image失败- npm install]](http://www.haobala.com/attached/image/news/202311/1028105a80.png)
网公网安备