Page 1 of 1

last records in a table

Posted: Sun 14 May 2006 14:20
by teunis
Dear,

D 6 programming.
I like to make a query that gives as result the last 30 records in a table
I don't want to use SELECT * FROM tablename and then Query.Last
It takes to much time.
It should be like SELECT * LIMIT nn,30 FROM tablename
The nn being the number of records in the table minus 30
How can I get the nn number?
Any suggestions?
Thanks Teunis

Posted: Mon 15 May 2006 06:26
by swierzbicki
This will works if you have an AutoInc field or DateTime field :
SELECT
x,
y
FROM
YourTable
ORDER BY
id desc limit 30