Paging queries for each database

Source: Internet
Author: User

  1. SQL Server Paging
  2. The first method of paging
  3. Parameters to be required:
  4. PageSize How many data are displayed per page
  5. PageNumber pages coming from the client
  6. Total number of records in the Totalrecouds table select COUNT (*) from table name
  7. TotalPages Total Pages
  8. totalpages=totalrecouds%pagesize==0?totalrecouds/pagesize:totalrecouds/pagesize+1
  9. Pages to calculate the previous pages bar data
  10. pages= pagesize* (pagenumber-1)
  11. SQL statements:
  12. Select Top PageSize * FROM table name where ID not in (select top pages ID from table name ORDER by ID) Order by ID
  13. The second method of paging
  14. PageSize How many data are displayed per page
  15. PageNumber pages coming from the client
  16. pages=pagesize* (pagenumber-1) +1
  17. Select Top PageSize * from table name where id>= (select Max (ID) from (select top pages ID from table name ORDER BY ID ASC) T)
  18. MySQL Paging
  19. Parameters to be required:
  20. PageSize How many data are displayed per page
  21. PageNumber pages coming from the client
  22. Total number of records in the Totalrecouds table select COUNT (*) from table name
  23. TotalPages Total Pages
  24. totalpages=totalrecouds%pagesize==0?totalrecouds/pagesize:totalrecouds/pagesize+1
  25. Pages Start location
  26. pages= pagesize* (pagenumber-1)
  27. SQL statements:
  28. SELECT * from table name limit pages, pageSize;
  29. MySQL paging relies on the keyword limit it requires two parameters: start position and pagesize
  30. Start Position = page Size * (pages-1)
  31. Starting position =pagesize* (PageNumber-1)
  32. Oracle Paging
  33. PageSize How many data are displayed per page
  34. PageNumber pages coming from the client
  35. Total number of records in the Totalrecouds table select COUNT (*) from table name
  36. TotalPages Total Pages
  37. totalpages=totalrecouds%pagesize==0?totalrecouds/pagesize:totalrecouds/pagesize+1
  38. StartPage Start position
  39. Startpage= pagesize* (pagenumber-1) +1
  40. Endpage=startpage+pagesize
  41. SQL statements
  42. Select A.* from
  43. (
  44. Select RowNum num, t.* from table name t where column = some value order by ID ASC
  45. ) A
  46. where A.num>=startpage and A.num<endpage
  47. DB2 Sub-page
  48. int startpage=1 //Start Page
  49. int endpage; //Termination page
  50. int pagesize=5; //Page size
  51. int pagenumber=1 //Request page
  52. Startpage= (pagenumber-1) *pagesize+1
  53. Endpage= (startpage+pagesize);
  54. SQL statements
  55. SELECT * FROM (select field 1, Field 2, field 3, field 4, field 5,rownumber () over (Order by sort field ASC) as rowID from table name) as a where A.rowid >= startpage and A.rowid <endpage
  56. Access Paging
  57. PageSize How many data are displayed per page
  58. PageNumber pages coming from the client
  59. pages=pagesize* (pagenumber-1) +1
  60. SQL statements
  61. Select Top PageSize * from table name where id>= (select Max (ID) from (select top pages ID from table name ORDER BY ID ASC) T)

Reprinted from: https://www.cnblogs.com/luanyichao/p/7825086.html

Paging queries for each database

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.