我有查询
SELECT ID,
post_title,
post_author,
max(case when meta_key='geo_latitude' then meta_value end) latitude,
max(case when meta_key='geo_longitude' then meta_value end) longitude,
( 3959 * acos( cos( radians(18.204540500000) )
* cos( radians( latitude ) )
* cos( radians( longitude )
- radians(-66.450958500000) )
+ sin( radians(18.204540500000 ) )
* sin( radians( latitude ) )
)
) AS distance
FROM `wp_posts`
LEFT JOIN `wp_postmeta`
on ID=post_id
WHERE post_type='place'
AND (meta_key='geo_latitude' OR meta_key='geo_longitude')
GROUP BY ID, post_title, post_author
ORDER BY ID ASC
这导致
Error Code: 1054. Unknown column 'latitude' in 'field list'
有没有办法在不使用内部/嵌套查询的情况下解决这个问题?