Find coordinates in X Km round

-4

I need help with this SELECT :

SELECT CONCAT(
'[', 
GROUP_CONCAT(JSON_OBJECT('id', h.hotel_id , 'nom', h.nom, 'estrelles', h.categoria, 'puntuacio', h.puntacio, 'tipus', h.tipus, 'descripcio', h.descripcio, 'adreca', h.adreca, 'lat', h.latitud, 'lng', h.longitud, 'web', h.web )),
']'
) 
FROM hotels h ;'

Check that given a point (lat and long) give us which restaurants / hotels are available in 'X' Km round in From JSON, being able to use it in the variable places of the html index.html

    
asked by Mohamed A.B 16.03.2018 в 09:58
source

1 answer

0

You could try something like this

SELECT h.nom, h.latitud, h.longitud 
FROM hotels h 
WHERE h.latitud between (40.4167754 + x) and (40.4167754 - x) 
AND h.longitud between (40.4167754 +y) and (40.416775 -y) 

Being X the rank in km passed to the respective equivalence in latitude

and being Y the rank in km passed to the respective equivalence in length

I think this could give you an approximate result, but it would not be 100% accurate.

    
answered by 16.03.2018 / 10:13
source