On Tue, 24 Dec 2002 10:00:46 +0100, Frank Barknecht <[EMAIL PROTECTED]> wrote: > >Hi, >Michael Engelhart hat gesagt: // Michael Engelhart wrote: > >> I use PostgreSQL and you can do something like: >> >> SELECT * FROM my_table LIMIT 25 OFFSET 25 >> >> which would return 25 rows starting with the 25th row in the result set. >> >> mySQL has something similar I believe which is something like: >> SELECT * ... LIMIT 5,10 > >Yep, you made my day. I was always using Postgres but the shop must >run on MySQL and this is the offset syntax I needed.
If you will allow me to slide into SQL pedantics for a moment, you should always use an ORDER BY clause when using LIMIT and OFFSET like that. Remember that SQL records are, by definition, unordered. Without an ORDER BY clause, there is no guarantee that the record order will be the same from query to query, so you could get unexpected gaps and repeats when fetching by pages like this. Now, in practical terms, Postgres and MySQL all DO have an internal ordering, so unless there are deletions and insertions in the interim, this isn't a real concern, but since the standard allows it, someday there will be an implementation that takes advantage of it. Forewarned is forearmed. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss