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. node.js - mysql如何通過knex查詢今天和七天內的匯總數據2. mysql 插入數值到特定的列一直失敗3. 360瀏覽器與IE瀏覽器有何區別???4. Python從URL中提取域名5. mysql - 百萬行的表中是否盡量避免使用update等sql語句?6. python - 在使用Pycharm時經常看到如下的樣式,小括號里紅色的部分是什么意思呢?7. javascript - 新浪微博網頁版的字數限制是怎么做的8. 怎么在網頁中設置圖片進行左右滑動9. javascript - 豆瓣的這個自適應是怎么做的?10. javascript - 用jsonp抓取qq音樂總是說回調函數沒有定義
