我有一個包含GPS座標經度和緯度的mysql表。查找接近距離GPS
我想提出一個請求,以獲得一個給定位置附近的記錄。
我已經試過2個請求和合並的結果,但它不是正確的......
//Req 1 - bigger than my position
$req1 = mysql_query('SELECT * FROM table WHERE latitude >= 47.6621549 and longitude >= 2.3547128 ORDER BY latitude, longitude');
//Req 2 - samller than my position
$req2 = mysql_query('SELECT * FROM table WHERE latitude <= 47.6621549 and longitude <= 2.3547128 ORDER BY latitude, longitude');
是否有可能有一個請求,使其? 有了這個,我想通過gmap distance API檢索給定位置的距離,我認爲這不是問題...
感謝您的回答。
這個答案可能會幫助您:http://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points – shannonman
這很可能是相關的你的問題http://dba.stackexchange.com/questions/4214/how-to-best-implement-nearest-neighbour-search-in-mysql –