How to add paging to a computed distance SQL

Source: Internet
Author: User
How to add paging to a computed distance SQL
$query =mysql_query (' select * from shop where lat > '. $lat. '-1 and Lat < '. $lat. ' +1 and lng> '. $lng. '-1 andlng < ; '. $lng. ' +1 ORDER by ACOS (SIN ($lat. ' * 3.1415)/*sin (LAT * 3.1415)/+cos (('. $lat. ' * 3.1415)/+/-) * COS (LAT * 3.1415) *cos (('. $lng. ') * 3.1415)/3.1415-(LNG */+)) * 6380 ASC limit 100 ');

This statement. If the limit is normal, then the number of pages and a few pages is followed by the number of pages. But after I add the distance calculation. Limit 100 only acts to calculate the data for 100 km of content. The number of pages and a few statements on a page cannot be added. If added, it cannot be displayed. Why is this? How do I change it?

------to solve the idea----------------------
Limit 100 is to return up to 100 records, which is not related to logic.

Limit $offset, $limit;
$offset is how many records are skipped.
How many records does the $limit take?
With these two, we can get the paging.

For example
$page = 2;
$pagesize 100;

Limit (2-1) *100, 100; You can get the records for the second page.
  • 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.