I want to query the five locations in the vicinity of two kilometers in the data table based on the longitude and latitude of the current location, if the query result does not have five locations, I want to expand the nearby range until the five locations are queried. I have come up with two solutions: the first solution is to use SQL statements completely... I want to query the five locations in the vicinity of two kilometers in the data table based on the longitude and latitude of the current location, if the query result does not have five locations, I want to expand the nearby range until the five locations are queried. I have come up with two solutions:
The first solution is to use SQL statements completely. if you use SQL statements completely, I don't know how to write this SQL statement,
The second solution is to first query and then judge in business integration. if five locations are not met, expand the nearby range and query again in the database until five locations are queried.
I don't know the efficiency of these two solutions. please give me some suggestions. Grateful.