I have a web application that displays registrations for various events. When there are more than 100 registrations for an event I would like to break the display into pages of 100 registrations each rather than list all of the registrations on one page. In such cases I want to have a summary page that has links to each of registration pages along with the range of names covered by that page. For example, a summary page might say:

1-100 (Adams-Clark)
101-200 (Collins-Easton)
201-300 (Edwards-Granger)


and so on. I know I can do this relatively easily in Perl by (pseudo-code):
1. SELECTing the total number of registrations and dividing by 100 to +get number of iterations for loop 2. for (index=1; index < num_iterations; index++){ SELECT RegistrantLastName FROM registrations ORDER BY Registrant +LastName LIMIT (100 * (i-1)) + 1,1 AS RangeStart; SELECT RegistrantLastName FROM registrations ORDER BY Registrant +LastName LIMIT (100 * i),1 AS RangeEnd; }

If possible, though, I would like to stick this all in a single query so that the DBMS is doing as much of the work as possible (and simplifying the logic in the application code).
Thoughts?

In reply to Can this be done entirely in MySQL? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.