我正在尝试选择基于wordpress自定义字段的db记录,这些字段包含lat和long,并且在此查询中遇到了一堵砖墙。有人看到任何明显我在忽视的东西吗?
谢谢!
WordPress数据库错误:[字段列表中的未知列'latitude.meta_value']
SELECT p.ID, p.post_title, (( ACOS( SIN( 39.1749 * PI() / 180 )
* SIN( `latitude.meta_value` * PI() / 180 )
+ COS( 39.1749 * PI() / 180 )
* COS( `latitude.meta_value` * PI() / 180 )
* COS(( -94.5804 - `longitude.meta_value` ) * PI() / 180 )) * 180 / PI() ) * 60 * 1.1515 ) AS distance
FROM wp_posts p
LEFT JOIN wp_postmeta latitude ON latitude.post_id = p.ID AND latitude.meta_key = 'neighborly_issue_lat'
LEFT JOIN wp_postmeta longitude ON longitude.post_id = p.ID AND longitude.meta_key = 'neighborly_issue_lng' HAVING distance < 10;
答案 0 :(得分:2)
您的逗号错误,请尝试:
SELECT p.ID, p.post_title, (( ACOS( SIN( 39.1749 * PI() / 180 )
* SIN( `latitude`.`meta_value` * PI() / 180 )
+ COS( 39.1749 * PI() / 180 )
* COS( `latitude`.`meta_value` * PI() / 180 )
* COS(( -94.5804 - `longitude`.`meta_value` ) * PI() / 180 )) * 180 / PI() ) * 60 * 1.1515 ) AS distance