您的位置:首頁技術文章
文章詳情頁

mysql報錯 unknown column ’a.plat’ in ON clause

瀏覽:61日期:2022-06-10 16:41:32

問題描述

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;

相關文章:
国产综合久久一区二区三区