OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
HOw to get the 10 most recent rows

From: Jens-Peter C. Hillers (jphremoteweb.de)
Date: Wed Sep 07 2005 - 10:41:55 CDT


Hello,

ill try to get the last ten rows without fetching the whole table (ODBC !)

the table

CREATE TABLE logtab (
 ts timestamp default TIMESTAMP,
 username varchar(255) NOT NULL default '',
 domain varchar(255) NOT NULL default '',
 action varchar(255) NOT NULL default '',
 data varchar(255) NOT NULL default ''
)

in postgres & mysql the query is:

SELECT * FROM logtab WHERE domain='$fDomain' ORDER BY ts DESC LIMIT 10

my first idea was:

SELECT *
FROM logtab
WHERE domain='$fDomain'
AND ROWNO < 11
ORDER BY ts

BUT If I've read the doc right maxDB does first fetch the fits ten rows an
then order it.

any help`?

regards
jph
___________________________
Dipl.-Ing. Jens-Peter C. Hillers
Remote Web Services GmbH
Tel: +49 40 25 49 06 22
Fax: +49 40 36 00 67 27
Email: jphremoteweb.de
____________________________