last records in a table

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
teunis
Posts: 48
Joined: Wed 01 Feb 2006 14:15
Location: Curacao

last records in a table

Post by teunis » Sun 14 May 2006 14:20

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

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Mon 15 May 2006 06:26

This will works if you have an AutoInc field or DateTime field :
SELECT
x,
y
FROM
YourTable
ORDER BY
id desc limit 30

Post Reply