Users of my DB can add their favorite locations to a DB. That table contains GPS coordinates as well as names. I want to minimize redundancy and when a user tries to add a new location to the DB
, check whether one already exists. I can surely go by GPS
coordinate. However, I also have to check the name of the location. Hence, users can misspell the identical location, so my check should be tolerant to false typing. On the other hand, they may mean something else.
This is not interactive, so no user feedback and I must avoid the number of false positives in the query. Any way to adjust the LIKE
lexicographical tolerance?
Here's the SQL code I thought of:
SELECT id FROM Locations AS L WHERE L = :LocationName AND distance(L.lat,L.lng,:lat,:lng) < 100;
where distance is the GPS distance in meters.