-1

How can I convert this pagination query to be compatible with MySQL:

'SELECT *
      FROM ( select p.*, ROWNUM rnum
      FROM ( select * from employees ) p
      WHERE ROWNUM <= '.(($current_page)*$perpage).' ) where ROWNUM  > '.(($current_page -1)*$perpage)';

This query is used inside a PHP script and works without problems.

Ben
  • 50,172
  • 36
  • 122
  • 141
JAHelia
  • 5,680
  • 15
  • 61
  • 113
  • but why the down vote .. this is unfair – JAHelia Sep 24 '13 at 06:28
  • I haven't downvoted but the tool tip says _"This question does not show any research effort..."_. There are over 1,000 questions on Stack Overflow that already deal with pagination in MySQL... I'd guess that people are downvoting because you haven't looked at any of them. – Ben Sep 24 '13 at 06:57

1 Answers1

1

You are looking for Limit in mysql

 limit ($current_page -1)*$perpage , ($current_page)*$perpage
Raab
  • 33,432
  • 4
  • 48
  • 63