Re: SQL select first 10 or so entries from a table

From: Ed prochak <ed.prochak_at_alltel.com>
Date: 19 Apr 2002 15:04:38 -0700
Message-ID: <e51b160.0204191404.949e106_at_posting.google.com>


Curtis,
You should read the original posting completely. Barry wanted a way to get the second batch of rows, and the batch after that. Your suggestion does not do that, but it does suggest yet another solution for Barry:

SELECT * FROM
( select rownum AS row_index, * from

   ( your select here....)
 ) batch
where row_index between 11 and 20;

(what have I done?! I actually found a way to make rownum useful!) I didn't test it, so I don't know how slow it would be. (likely very slow if the innermose select returns many rows?)

  Ed

cvonancken_at_orkand.com (Curtis VonAncken) wrote in message news:<b712ca72.0204170949.3a671499_at_posting.google.com>...
> One way to do this is too do:
>
> SELECT * FROM
> (your select here....)
> WHERE ROWNUM < 11;
>
> This way of you have any sorting the ROWNUM won't screw it up. Not the
> cleanest way but an ok solution...
>
> Curt
>
>
>
> ed.prochak_at_alltel.com (Ed prochak) wrote in message news:<e51b160.0204161255.68c7ab49_at_posting.google.com>...
> > bbulsara23_at_hotmail.com (barry) wrote in message news:<747f1dec.0204140251.54ee7eb0_at_posting.google.com>...
> > > Hello, imagine I have lots of tables each containing 30-75,000
> > > entries.
> > >
> > > The query
> > >
> > > SELECT * FROM tablename WHERE something=somethingelse
> > >
> > > returns on occasions many thousand hits.
> > >
> > > What sort of SQL construct do you use to say give me the first 5
> > > entries.
> > > Then what SQL do you use to get the next 5 entries.
> > > Then the SQL to get the 5 after that etc, for a table in a general
> > > sense. I don't care about the 'order' of the results that come back, I
> > > just want to display things in bite size chunks (like a hitset, and if
> > > the user doesn't find the result they're after in the client
> > > front-end, they hit the "next" button).
> > >
> > > Again thank you in advance to everyone that thinks about, or posts,
> > > solutions to this query.
> > > Barry
Received on Sat Apr 20 2002 - 00:04:38 CEST

Original text of this message