Search code examples
mysqlsqldatabasedrupaldrupal-7

so many values in my DB


I have 4,000,000 rows in a table in my db how i can take them 100 by 100?


Solution

  • SELECT * FROM YourTable
    ORDER BY Id
    LIMIT 0,100
    

    and next call

    SELECT * FROM YourTable
    ORDER BY Id
    LIMIT 100,100
    

    and then

    SELECT * FROM YourTable
    ORDER BY Id
    LIMIT 200,100
    

    And, of course, don't repeat your query in code 10 000 times, but put it in for loop.