On Wed, 24 Aug 2005, Harald Fuchs wrote:
"Praveen KS" <[EMAIL PROTECTED]> writes:
Can anyone help with a query to retrieve latest N records.
No auto_increment field.
No date field.
Primary key exists and is populated with random unique values.
This means that the only possible definition for "latest" is "highest slno".
Translated to SQL:
SELECT slno, name
FROM tbl
ORDER BY slno DESC
LIMIT <N>
no, it was stated "random unique values" those cannot be sorted.
what was asked for was
<FAKE SQL>
SELECT * FROM table ORDER BY __INSERT__ DESC LIMIT N;
</FAKE SQL>
depending on your db config you might be able to do this outside of sql by
parsing the binary log. It is a history of updates to the database, in
chronological order.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- -
- Jason Pyeron PD Inc. http://www.pdinc.us -
- Partner & Sr. Manager 7 West 24th Street #100 -
- +1 (443) 921-0381 Baltimore, Maryland 21218 -
- -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information. If you
have received it in error, purge the message from your system and
notify the sender immediately. Any other use of the email by you
is prohibited.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]