Jump to content

Recommended Posts

I'm doing some research on geocoding and found a mysql script that appears to work fine on my test server, but not on my live server. The test server has mysql 5.0.67, and my live server has 5.0.66a - but I'm thinking this isn't the problem.

 

Nutshell, the query calls a function ATAN2, which returns the error "FUNCTION my_table.ATAN2 does not exist" on my live server, but returns records on my test server. I copied and pasted the same query to both, so I believe I've eliminated query syntax as the problem.

 

Note, I did have to run mysql_fix_privilege_tables on the database recently. The database was and is working fine for everything else I'm doing, but this query revealed some underlying issues. Perhaps I need to run another kind of fix on it as well?

 

Thoughts?

Link to comment
https://forums.phpfreaks.com/topic/158526-function-atan2-does-not-exist/
Share on other sites

It's for a geo radius search.

 

    SELECT `id`, X(gm_coor) AS `latitude`, Y(gm_coor) AS `longitude`,
      ATAN2(
        SQRT(
          POW(COS(RADIANS(30.311325)) *
               SIN(RADIANS(Y(gm_coor) - -91.909917)), 2) + 
          POW(COS(RADIANS(X(gm_coor))) * SIN(RADIANS(30.311325)) - 
              SIN(RADIANS(X(gm_coor))) * COS(RADIANS(30.311325)) * 
              COS(RADIANS(Y(gm_coor) - -91.909917)), 2)), 
        (SIN(RADIANS(X(gm_coor))) * SIN(RADIANS(30.311325)) + 
         COS(RADIANS(X(gm_coor))) * COS(RADIANS(30.311325)) * 
         COS(RADIANS(Y(gm_coor) - -91.909917)))
      ) * 6372.795 AS `distance` 
    FROM `my_table`
    HAVING `distance` < 1

Interesting, SELECT ATAN2(PI(),0); (from the refman) returns a value. That query does work on another server just fine, though. Hmmm, what does that mean?

 

I'm not quite sure what you're referring to - dump the existing list of functions that [i've] created. Can you elaborate?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.