Data not pulled from mysql at particular zoom level laone

Between command not working correctly for geo coordinates

Select * from table_name where loc_lng BETWEEN $ln2 AND $ln1 AND loc_lat BETWEEN $la2 AND $la1

The code works perfectly fine when $ln2 is smaller than $ln1 and $la2 is smaller than $la1, but it dosent work when the values $ln1 is greater than $ln2 and $la1 is greater than $la2. The ln and la are geo coordinates so sometimes one will be bigger than the other.

Answers


That's to be expected. You need additional logic to define the minLatitude, maxLatitude, minLongitude and maxLongitude BEFORE you pass the values to the query.

Then your query can be

Select * from table_name where loc_lng BETWEEN $minLongitude AND $maxLongitude AND loc_lat BETWEEN $minLatitude AND $maxLatitude

Need Your Help

How to use Log4j2 xml Rewrite appender for modifying LogEvent before it logs in file

java xml logging log4j2 appender

I want to use Rewrite appender in my log4j2.xml file so that before logging I can modify logs. I have not get much helps from google. As per log4j2 documents Rewrite is an interface has rewrite met...

how to add figures from multiple worksheets in excel using ranges

excel excel-formula

I have multiple worksheets all using the same template