select block rows in block from a range of 10 in 10 by looping the query?

Asked

Viewed 49 times

-2

I have a table of 500 thousand precise lines of this 500 thousand lines only of 1000 in 1000 for example select * from table limit 1000 offset 0; the range would be to stop at 1000 and then make another select starting 1001 to 2000 for example only that I need to do this once in a php script

  • You will have to create a paging system, and in it you will inform how many should be presented per page.

  • I’ll try Daniel’s worth

  • 1

    Is the same question? you can edit it and add more details, no need to create a new.

1 answer

1

<?php 

var $quantidadeRegistro = 5000; //quantiade registro no banco

var $limit = 1000; 
var $offset = 0;

var $select = "";

//criar os select no banco
for($i = 1; $i <= $quantidadeRegistro ; $i += 1000){ 
    $select = $select + "select * from [tabela] limit " . $limit . " offset " . offset;
}

$offset = $limit;

if($quantidadeRegistro > $limit){
    $limit = $limit + 1000;
} else {
    $limit = $limit + ($quantidadeRegistro - $limit);
}

if($quantidadeRegistro > $limit){
$limit = $limit + 1000;
} else {

}

}

I think that’s about what you need!

  • hello, @Edvaldo. It would be nice for you to replay your answer here: http://answall.com/q/116198/91

Browser other questions tagged

You are not signed in. Login or sign up in order to post.