hi guys, This is the query of PHP using MySQL. can anyone please convert this query to sqlite query?
Query:
select SQRT(POW(latitude, 2) + POW(longitude, 2)) *110 as dist from route
Best Regards, Thanks
hi guys, This is the query of PHP using MySQL. can anyone please convert this query to sqlite query?
Query:
select SQRT(POW(latitude, 2) + POW(longitude, 2)) *110 as dist from route
Best Regards, Thanks
It's trivial to register PHP's sqrt with sqlite_create_function.
sqlite_create_function($sqlite_db, "sqrt", "sqrt", 1);
Without registering, you can use:
php('sqrt', value);
I have done it with the help of "pascal".
The query becomes:
SELECT
*
FROM
(
SELECT
temperature,
climate,
temperatureTime,
photoURL,
(((latitude - 37.331689) * (latitude - 37.331689)) + (longitude - (-122.030731)) * (longitude - (-122.030731))) * (110 * 110) AS dist
FROM
weather
)
AS tab
WHERE
tab.dist <= (1.0 * 1.0);
This query is used to find out the nearest coordinates of locations around me within 1 KM.