0

I have to print some SQL's select's requests answers on a web page.
Because it's a to large result, i need to print it 500 per 500.
Like phpmyadmin, how can i say (with a SQL request) to get my results per 500 ?

Actualy i'm doing like this :

SELECT * FROM taches WHERE id<=1435 ORDER BY id DESC LIMIT 500

And updating the id limit at every click on the "next button". Can i say to SQL something like this :

SELECT * FROM taches ORDER BY id DESC LIMIT 500 EXCEPTFIRSTRESULT 500

(I know this can't work, but is it possible with an other way ? Thanks.

Antoine Duval
  • 342
  • 3
  • 20
  • `distinct *` is useless because the PK will be included which makes all rows unique (by definition) and therefor `distinct` will not remove any rows. Btw: which DBMS are you using? –  May 20 '15 at 09:33
  • Thanks, it's true the distinct is useless (It is a habit) But it don't solve my problem :/ – Antoine Duval May 20 '15 at 09:35
  • It's a bad habit. And again: which DBMS are you using? Does it support OFFSET? –  May 20 '15 at 09:35
  • I'm using phpmyadmin with wamp. Is that what ou need ? So "OFFSET 500" will ignore the 500 first result ? I think my answer is here http://stackoverflow.com/questions/187998/row-offset-in-sql-server. Thank you so much. – Antoine Duval May 20 '15 at 09:36

1 Answers1

0

Thanks to jarlh, the answer is :

"SELECT * FROM taches ORDER BY taches.id ASC LIMIT 500 , 500".

Have a good day :D

Community
  • 1
  • 1
Antoine Duval
  • 342
  • 3
  • 20