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表中有l(wèi)at字段,沒有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;
相關(guān)文章:
1. docker 17.03 怎么配置 registry mirror ?2. angular.js - angularJS service里面存儲的數(shù)據(jù)能夠直接和HTML頁面交互嗎?3. 請教各位大佬,瀏覽器點 提交實例為什么沒有反應(yīng)4. javascript - 七牛接口如何在前端調(diào)用?5. css3里rotate怎么實現(xiàn)如圖的效果6. html - chrome 下 transiton translateX(10px) 后字體變化7. javascript - 使用location.href進(jìn)行頁面跳轉(zhuǎn)時,并不立即跳轉(zhuǎn)?8. javascript - 圖片請求失敗怎么去掉左上角的小圖標(biāo)?9. css3 - 何時需要 flex-basis: 100% ?10. mysqld無法關(guān)閉
