-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
  • 51,770
  • 36
  • 127
  • 149
JAHelia
  • 6,934
  • 17
  • 74
  • 134
  • 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
  • 34,778
  • 4
  • 50
  • 65