-1

半径検索でアプリケーションを作成しています。これは私が学んだ例です

https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql

私の場合

そうです

SELECT (3959 * acos(cos(ラジアン(-37.814107)) * cos(ラジアン(緯度)) * cos(ラジアン(lng) - ラジアン(144.96327999999994)) + sin(ラジアン(-37.814107)) * sin(ラジアン(緯度) )))) AS距離;

緯度 = -37.8141070000、経度 = 144.9632800000 の場合

SELECT (3959 * acos(cos(ラジアン(-37.814107)) * cos(ラジアン(-37.8141070000)) * cos(ラジアン(144.9632800000) - ラジアン(144.96327999999994)) + sin(ラジアン(-37.814107)) * sin(ラジアン( -37.8141070000)))) AS 距離;

MySQL が距離を NULL として出力するのはなぜですか? 私は何か間違ったことをしましたか?

どうすれば修正できますか?申し訳ありませんが、私は数学が本当に苦手です。

4

1 に答える 1

0

基本的な SQL クエリ

SELECT * FROM table

フィールドとして緯度と経度を含むクエリにMySqlテーブルが必要です。すなわち

SELECT (3959 * acos(cos(radians(-37.814107)) 
       * cos(radians(lat)) * cos(radians(lng) - radians(144.96327999999994))
        + sin(radians(-37.814107))
        * sin(radians(lat)))) AS distance FROM table;
于 2015-07-04T09:35:20.150 に答える