Michdd Posted July 18, 2009 Share Posted July 18, 2009 Is there a way I can get the last 3 results of a query in ASC order without running more than one query? I know I can do this way: $query = "SELECT * FROM `table` LIMIT " . (Query to count results) - 3 . ", 3"; But is there a better way? Quote Link to comment Share on other sites More sharing options...
ldougherty Posted July 19, 2009 Share Posted July 19, 2009 Sorting it ASC is what makes your second query necessary. If you wanted to select the last 3 results you could do DESC LIMIT 3 If you wante to do DESC LIMIT 3 you could then reverse the results array with array_reverse http://us2.php.net/manual/en/function.array-reverse.php Quote Link to comment Share on other sites More sharing options...
Michdd Posted July 19, 2009 Author Share Posted July 19, 2009 Oh, good idea thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.