Yet another solution SET ROWCOUNT 1 SELECT id FROM table ORDER BY id DESC Only works if there is an index on id and the RDBMS support backward scans
Chuck
[EMAIL PROTECTED] wrote:
Another solution : For your query, try "SELECT MAX(id) FROM table" That works with mysql.
-----Message d'origine-----
De : dan [mailto:[EMAIL PROTECTED] Envoyé : samedi 25 octobre 2003 11:44
À : [EMAIL PROTECTED]
Objet : SQL Syntax quickie
Hi,
I've looked around to not much avail, what I'm looking for is a SELECT query that selects the last record in a database. Each table has the primary field "id", to which auto increments on each input. I don't want to have to load the entire db, cycle through it until I find the last one, the program needs to react fast, not being slowed down by having to cycle through database records.
Basically what happens is the program enters information using INSERT, and then it needs to re-read the data it's just sent to verify it, and get the id number that auto_increment assigned it.
Is this possible? Does this make sense? *laugh*
Many thanks, Dan
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]