Answer the question
In order to leave comments, you need to log in
How to correctly get points with coordinates inside a rectangle?
Hello! At me such situation... There are coordinates of two points of a rectangle (left top and right lower corner). It is necessary to get from the database the coordinates that are inside this rectangle.
The following request came up:
SELECT * FROM `coordinates`
WHERE (`lat` BETWEEN '{$latitude2}' AND '{$latitude1}') AND (`lng` BETWEEN '{$longitude1}' AND '{$longitude2}')
SELECT * FROM `coordinates`
WHERE (`lat` BETWEEN '-7.987931' AND '6.775799') AND (`lng` BETWEEN '172.152671' AND '-168.106551')
Answer the question
In order to leave comments, you need to log in
Correct something like this
https://dev.mysql.com/doc/refman/8.0/en/spatial-re...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question