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. javascript - SuperSlide.js火狐不兼容怎么回事呢2. 一个走错路的23岁傻小子的提问3. java - 创建maven项目失败了 求解决方法4. 运行python程序时出现“应用程序发生异常”的内存错误?5. node.js - 函数getByName()中如何使得co执行完后才return6. java-se - 正在学习Java SE,为什么感觉学习Java就是在学习一些API。7. python - 如何使用pykafka consumer进行数据处理并保存?8. javascript - git clone 下来的项目 想在本地运行 npm run install 报错9. 主从备份 - 跪求mysql 高可用主从方案10. python - django 里自定义的 login 方法,如何使用 login_required()
