Limit SQL query result in MySQL

前端 未结 7 1642
無奈伤痛
無奈伤痛 2021-02-08 16:10

I would like to limit the amount of rows I fetch in MySQL. Can you show me how?

ex:

  • 1st query I would like to retrieve only the first 10,000 records
  • <
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-08 16:50

    MySQL and PostgreSQL support OFFSET that is usually used with a LIMIT clause.

    SELECT column FROM table
    LIMIT 10000
    
    SELECT column FROM table
    LIMIT 10000 OFFSET 10000
    

提交回复
热议问题