In the system, when searching for a nearby restaurant, you need to obtain information about the restaurant at a specified distance according to the current latitude and longitude. In this demand, the distance between a restaurant and the current latitude and longitude must be calculated based on the latitude and longitude. Previously, we used the sybase Database to calculate the distance between two points after obtaining the data. However, the sybase Database has been deprecated, so I want to query qualified restaurants using SQL as conditions.
The SQL statements are as follows:
Select * from mer where sqrt (113.60189578775-mer_gps_long1_) * PI () * 12656 * cos (24.80864699442 + mer_gps_latitude)/2) * PI ()/180) /180) * (113.60189578775-mer_gps_long1_) * PI () * 12656 * cos (24.80864699442 + mer_gps_latitude)/2) * PI ()/180)/180 )) + (24.80864699442-mer_gps_latitude) * PI () * 12656/180) * (24.80864699442-mer_gps_latitude) * PI () * 12656/180) <5
The queried data is a restaurant with a distance of less than 5km.