MySQL offset infinite rows

前端 未结 9 2230
星月不相逢
星月不相逢 2020-11-22 16:25

I would like to construct a query that displays all the results in a table, but is offset by 5 from the start of the table. As far as I can tell, MySQL\'s LIMIT

9条回答
  •  暖寄归人
    2020-11-22 16:53

    Just today I was reading about the best way to get huge amounts of data (more than a million rows) from a mysql table. One way is, as suggested, using LIMIT x,y where x is the offset and y the last row you want returned. However, as I found out, it isn't the most efficient way to do so. If you have an autoincrement column, you can as easily use a SELECT statement with a WHERE clause saying from which record you'd like to start.

    For example, SELECT * FROM table_name WHERE id > x;

    It seems that mysql gets all results when you use LIMIT and then only shows you the records that fit in the offset: not the best for performance.

    Source: Answer to this question MySQL Forums. Just take note, the question is about 6 years old.

提交回复
热议问题