0

So I've done a lot of research and I cannot seem to find someone with the same problem. I was using a query to find to closest destinations with this document:

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

It worked find when I was doing local tests. However, when I switched to AWS RDS, the calculation went very wrong.

It all comes down to this: When I do a query with a stored value on my localhost mysql, it returns a different result from when I do a query with an actual value.

(Only one row in my table, and the longitude value is -177.744302.)

So when I did:

SELECT (longitude * pi() / 180) AS temp
FROM table1;

I would get -2.0550257453625447.

But when I use:

SELECT (-177.744302 * pi() / 180) AS temp 
FROM table1;

I would get -3.1022232966.

I have no idea why this is happening and I can't seem to figure out why. And this only happens when I'm doing it on localhost mysql. When I use it on AWS RDS the result for both queries are -3.102223966. And mathematically -3.102223966 is the correct answer, but -2.05502574 is the one I need to calculate the correct distance. So this is very ironic and confusing to me.

AWS RDS has mysql version 5.6.13 and localhost mysql is 5.6.14, but I don't think this is the reason why. But it just does not make sense at all. If anyone has been through similar problem please help me.

2 Answers 2

2

The value in your table is -117.744302 and not -177.744302

Sign up to request clarification or add additional context in comments.

1 Comment

I'm so sorry guys, this is such a stupid mistake. I guess I've just been looking at the numbers for over 5 hours, because I was trying to migrate from local to RDS. It was a typo in my data, and that's why there's different results from local and rds. Thank you for your time.
0

-2.0550257453625447 * 180 / pi() = -117.744.. , not -177.744... , looks like a typo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.