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. mysql - 這條聯合sql語句哪里錯了2. mysql優化 - 關于mysql分區3. 請教各位大佬,瀏覽器點 提交實例為什么沒有反應4. java - Atom中文問題5. java - MySQL中,使用聚合函數+for update會鎖表嗎?6. css3 - 這個形狀使用CSS怎么寫出來?7. javascript - 為什么這個點擊事件需要點擊兩次才有效果8. node.js - 在vuejs-templates/webpack中dev-server.js里為什么要exports readyPromise?9. javascript - ionic2 input autofocus 電腦成功,iOS手機鍵盤不彈出10. java - C語言算法題-韓信點兵 求解?
