Do you mean the last five rows in the database or the last five rows entered into the database? .... Either way,
Last five rows select [someColumn] from [someTable] ORDER BY [someColumn] DESC LIMIT 0, 5 If the total number of rows is known select [someColumn] from [someTable] ORDER BY [someColumn] LIMIT (totalNum - 5), -1 Or if you have a timestamp and you need the last five entered select [someColumn] from [someTable] ORDER BY timestamp DESC LIMIT 0, 5 I hope this helps. -----Original Message----- From: Christopher Lyon [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 10:26 AM To: [EMAIL PROTECTED] Subject: sql query using select and row functions I am trying to do an sql query and am trying to select the last x rows from the database. I see the limit function but that seems like that is from the first row down. I want to start from the last row to the first row. So, selecting the last 5 rows for instance? Can this be done? --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php