I want to find a nearest location from following database table
Address Latitude longitude
Kathmandu 44600, Nepal
The SQL have a problem. In table like:
`ubicacion` (
`id_ubicacion` INT(10) NOT NULL AUTO_INCREMENT ,
`latitud` DOUBLE NOT NULL ,
`longitud` DOUBLE NOT NULL ,
PRIMARY KEY (`id_ubicacion`) )
The id_ubicacion change when use:
SELECT `id_ubicacion` , ( 3959 * ACOS( COS( RADIANS( 9.053933 ) ) * COS( RADIANS( latitud ) ) * COS( RADIANS( longitud ) - RADIANS( - 79.421215 ) ) + SIN( RADIANS( 9.053933 ) ) * SIN( RADIANS( latitud ) ) ) ) AS distance
FROM ubicacion
HAVING distance <25
ORDER BY distance
LIMIT 0 , 20