Paging code for common databases

Source: Internet
Author: User
Mysqlsql code
  1. Select * from cat limit ?,?
  2. Select * from cat limit 20000,100
  3. Retrieve 20,000th records starting from 100 records in the cat table, that is, records ranging from 20000 to 20099
  4. Select * from cat limit?
  5. Select * from cat limit 100
  6. Retrieve records ranging from 1 to 100 from the cat table
  7. Select * from cat order by rand () limit?
  8. Select * from cat order by rand () limit 100
  9. Randomly retrieve 100 records from the cat table

Oraclesql code

  1. Select * from (select *, rownum _ from cat where rownum <= ?) Where rownum _>?
  2. Select * from (select *, rownum _ from cat where rownum <= 20099) Where rownum _> 19999
  3. Retrieve 20,000th records starting from 100 records in the cat table, that is, records ranging from 20000 to 20099
  4. Select * from cat where rownum <=?
  5. Select * from cat where rownum< = 100
  6. Retrieve records ranging from 1 to 100 from the cat table
  7. Select * from (select * from cat order by dbms_random.value) Where rownum <?
  8. Select * from (select * from cat order by dbms_random.value) Where rownum <100
  9. Randomly retrieve 100 records from the cat table

Hsqldbsql code

  1. Select * from cat limit? ?
  2. Select * from cat limit 20000 100
  3. Retrieve 20,000th records starting from 100 records in the cat table, that is, records ranging from 20000 to 20099
  4. Select * from cat top?
  5. Select * from cat Top 100
  6. Retrieve records ranging from 1 to 100 from the cat table

SQL serversql code

  1. Select top? * From cat order by newid ()
  2. Select Top 100 * from cat order by newid ()
  3. Randomly retrieve 100 records from the cat table

 

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.