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;
相關文章:
1. html5 - datatables 加載不出來數(shù)據(jù)。2. node.js - mongodb查找子對象的名稱為某個值的對象的方法3. 測試自動化html元素選擇器元素ID或DataAttribute [關閉]4. html5和Flash對抗是什么情況?5. 利用IPMI遠程安裝centos報錯!6. javascript - QQ第三方登錄的問題7. 在mac下出現(xiàn)了兩個docker環(huán)境8. 運行python程序時出現(xiàn)“應用程序發(fā)生異常”的內存錯誤?9. spring-mvc - spring-session-redis HttpSessionListener失效10. 正在使用electron和node.js做桌面應用,需要實時監(jiān)聽是否有網(wǎng)絡連接,node或者electron是否可以做到

網(wǎng)公網(wǎng)安備