我有以下查询:
SELECT
locations.*,
(SELECT COUNT(id) FROM location_scores WHERE location_id = locations.id) AS total_votes,
(SELECT AVG(location_score) FROM location_scores WHERE location_id = locations.id) AS rating,
(SELECT COUNT(id) FROM location_views WHERE location_id = locations.id) AS total_views,
(SELECT COUNT(id) FROM location_procedures WHERE location_id = locations.id) AS total_procedures,
(SELECT ((ACOS(SIN(32.9063840 * PI() / 180) * SIN(location_latitude * PI() / 180) + COS(32.9063840 * PI() / 180) * COS(location_latitude * PI() / 180) * COS((-96.8590890 - location_longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) FROM locations) AS distance
FROM locations
WHERE distance <= '5'
AND locations.id IN ('57', '57', '57', '57', '57', '57', '57', '57', '57', '57', '68', '68', '70', '73', '73', '76', '76', '76', '76', '76', '77', '77')我不断收到以下错误:
Unknown column distance in where clause