I have two table as shown below:
tbl_properties and tbl_postcodes
It shall list the properites in surrounding 5 kms of the selected postcode/s.
I am trying to get the result with below query but its not getting correct results.
SELECT* FROM (
SELECT p.*,
ROUND(
60 * 1.1515 * 1.609344 * DEGREES(
ACOS(
COS(RADIANS(pc.latitude
)) * COS(RADIANS(p.lat
)) * COS(RADIANS(pc.longitude
- p.lng
)) + SIN(RADIANS(pc.latitude
)) * SIN(RADIANS(p.lng
))
)
),
2
) AS distance
FROM properties
AS p JOIN postcodes_geo AS pc ON (p.postcode_id
= pc.id
)
WHERE p.postcode_id IN (792,790,786,12613) ) AS ftbl WHERE distance <= 5