Ordering System (5) -- getting nearby restaurants

Source: Internet
Author: User
Tags sybase sybase database

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.