I have a database of addresses and I'm setting up a map search option on my website. The database has data such as address, price, numberOfBedrooms, numberOfBathrooms, Latitude, Longitude, etc. A user has the option to search by City and Price. Once a user clicks the search button I construct my sql query and return the results. How can I get the latitude and longitude range in 4 separate variables (ie. Highest Lat, Lowest Lat, Highest Long, and Lowest Long) in order to set the boundaries for google maps?
mysql query example:
SELECT * FROM table WHERE City = "city" AND Price BETWEEN "100000" AND "200000"
Let's say it returned 50 results. Would it be more efficient to do more sql queries to find the min and max lat/lng coordinates, or is there a way to loop through the results to find the min/max lat/lng using only one query that would be quicker?
EDIT: I should point out that I also need it to return all the other columns as well as the highest and lowest lat/lng
lat
andlng
in two columns, or one comma-separatedlatlng
string? - lufc