I'm trying to make a query that select users located on an area. I've this table:
Users
(user_id
, username
, user_latitude
, user_longitude
)
I have an area defined by 2 points:
How to get the users with a geoposition contained on the area?
Thank you :)
A naive but simple approach could look like this, assuming your area is similar to a rectangle:
SELECT * FROM Users WHERE (user_latitude >= 1.2393 AND user_latitude <= 1.5532)
AND (user_longitude >= -1.8184 AND user_longitude <= -1.654)
For more sophisticated demands, you should use geospatial functions.