Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I've just looked at one of my old documentation pages I wrote and I have this quote from 3 years ago:

    To create the effect of limit function in MySQL you need to use the automatically-on-the-fly
    created rownum column. You can select and have a where clause that limits the amount of rows
    you want. Like: 'select id,name from table where rownum >= 1 and rownum = 10' would get the
    first 10 results from the database.
    • They're not quite the same. Your notes give the solution to finding records 1 to 10 (or whatever), but won't work for records 11 to 20. The difference is that this example is designed to function for a minimum rownum greater than 1. You can't put that in directly in the way you said because rownum is based on the order of results from the query, and if you specify rownum > 1 (or rownum > n for n > 1), nothing will be returned. In English, such a query would say, "Give me a result set with no first row," which isn't possible, save for the empty set. :)

      The incredibly complex SQL hackery above gets around that. It's a little like saying:

      $ head -20 file | tail -10

      to get lines 11-20 of a file.

      --
      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers