educative.io

Query for Grid fetching is wrong

Select * from Places where Latitude between X-D and X+D and Longitude between Y-D and Y+D and GridID in (GridID, GridID1, GridID2, …, GridID8).

The above query should be like below as we are searching based on GridID
Select * from Places where GridID in (GridID, GridID1, GridID2, …, GridID8).

For searching in a grid, we need to check its location that in which grid we need to find. That’s why we will first check its longitude and latitude and then go in that specific grid. By just searching on grid ID we can’t find the exact location.