On Friday 13 December 2002 14:43, Peter Vertes wrote: > Is it possible to do nested select statements with MySQL ? Basically > I'm trying to display the last 5 rows that got inserted into a table. My > SQL query looks like this: > > select * from tablename limit ((select count(*) from tablename) - 5), -1; > > In theory it works for me :) but MySQL complains. Is it possible to do > nested queries with MySQL ? Does anyone have a better way of displaying > the last x amount of rows inserted into a table ? Thanks in advance...
There is no internal order in the table, there is no last record and nope the first row in the table. If you have auto_increment column, you can do it like SELECT .... ORDER BY id DESC LIMIT 5; -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com --------------------------------------------------------------------- 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