-1

A mysql table contain 100 rows. I am trying to display first 20 rows with 5 rows per page.

I think query should be like this

    SELECT * FROM `table` top 20 LIMIT 0, 5

but how can i use this concept. waiting for your help.

swdpankaj
  • 107
  • 2
  • 11

1 Answers1

0

You can use LIMIT and OFFSET controls, LIMIT is for max rows you want to show and OFFSET is the starting position:

   SELECT * FROM db_name ORDER BY db_table LIMIT 5 OFFSET 0
mshllakuu
  • 3
  • 1
  • I use but this query displays all the records of the table 5 row per page. In my code offset will be changed dynamically. I want to display only 20 records. In first page 0-5 , in second page 5-10, in third page 10-15 and in 4th page 15-20 and no more records want to display. – swdpankaj Dec 30 '16 at 13:50