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.