티스토리 뷰

SELECT *,
           SQRT( POW( ( (69.1/1.61) * ('37.5333131' - A.centerLat)), 2)
               + POW(( (53/1.61) * ('127.0862168' - A.centerLng)), 2)) AS distance
           FROM (
select max(centerLat) as centerLat, max(centerLng) as centerLng
from rectId
group by groupIdx
         ) A
        WHERE centerLat > '37.5333131' - 10 / (69.1/1.61)
          AND centerlat < '37.5333131' + 10 / (69.1/1.61)
          AND centerLng > '127.0862168' - 10 / (53/1.61)
          AND centerlng < '127.0862168' + 10 / (53/1.61)
        HAVING distance < 3
        order by distance asc


SELECT *,
  ROUND( SQRT( POW( ( (69.1/1.61) * ('52.64' - latitude)), 2) +
         POW(( (53/1.61) * ('6.88' - longitude)), 2)), 1) AS distance
FROM lp_relations_addresses
WHERE latitude > '52.64' - 10 / (69.1/1.61)
  AND latitude < '52.64' + 10 / (69.1/1.61)
  AND longitude > '6.88' - 10 / (53/1.61)
  AND longitude < '6.88' + 10 / (53/1.61)
HAVING distance < 10
ORDER BY distance DESC



-- 37.5333131,127.0862168,14.65z

 

널린게 쿼리이다.

 

 

stackoverflow.com/questions/41081165/sql-search-near-longitude-and-latitude

 

SQL search "near" longitude and latitude

I'm trying to write a search bar that searches near a location. For now it's hard coded. The statement works until I add the like statements for longitude and latitude. Is there a better way to do ...

stackoverflow.com

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함