Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Querying Select Number of Rowsby Arguile (Hermit) |
on Jun 05, 2001 at 03:52 UTC ( [id://85665]=note: print w/replies, xml ) | Need Help?? |
As runrig said, syntaxes can vary... so here are some common ones: PostgreSQL, MySQL, and some other have variants of the LIMIT x OFFSET y clause. This always (to my knowledge) appears as the last clause in the query.
In Oracle you can use the "rownum" indexing of the recordset to return a specific number of records.
If you're working with an M$ DBMS like SQL Server (I refuse to allow Access to be called a DBMS) or one Informix's you can use the TOP syntax. TOP is part of the SELECT clause as seen below.
I know nothing of DBI so the next statement is a generality. The benefits to using the limiting at the DBMS side are smaller recordsets transfered back and often quicker queries (DBMS dependant), you do loose a certain amount of portability however. Staying with straight ANSI SQL and datatypes is always a problem though.
In Section
Seekers of Perl Wisdom
|
|