mysql 報錯 ON 子句中的未知欄位 'a.plat'
漂亮男人
漂亮男人 2017-06-30 09:54:48
0
1
1006
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)
phpcn_u1582

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;
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!