I am trying to make a query to the database so that I can list results close to the user (by latitude and longitude). I am currently using a query that is in the Google Maps documentation. The problem is when I try to limit to page (from 10 rows). MySql returns repeated items in different pages. This is the query I do:
SELECT p.producto_id ,
(6371 * acos( cos( radians(-34.5996599) ) * cos( radians( p.producto_map_latitud ) ) * cos( radians( p.producto_map_longitud ) - radians(-58.5250757) ) + sin( radians(-34.5996599) ) * sin( radians( p.producto_map_latitud ) ) ) ) AS distancia
FROM productos p
WHERE p.producto_publicado = 1
ORDER BY distancia ASC
LIMIT 0, 10
This returns me:
When I go to the next page, you can see the first repeated item:
The script for the second page is:
SELECT p.producto_id ,
(6371 * acos( cos( radians(-34.5996599) ) * cos( radians( p.producto_map_latitud ) ) * cos( radians( p.producto_map_longitud ) - radians(-58.5250757) ) + sin( radians(-34.5996599) ) * sin( radians( p.producto_map_latitud ) ) ) ) AS distancia
FROM productos p
WHERE p.producto_publicado = 1
ORDER BY distancia ASC
LIMIT 10, 10
Beforehand, thank you very much!