Limit SQL query result in MySQL

前端 未结 7 1664
無奈伤痛
無奈伤痛 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:40

    in mysql you do as follows

    SELECT * FROM PERSON_TBL LIMIT 0, 1000 
    
    SELECT * FROM PERSON_TBL LIMIT 1000, 1000 
    

    Query 1 will fetch first 1000 records,

    Query 2 will fetch next 1000 records

    Syntax for limits clause

    LIMITS OFFSET, ROWCOUNT

    Where ROWCOUNT give number of row to fetch

    OFFSET gives from which row to fetch more info here

提交回复
热议问题