CyberGuru Posted June 22, 2011 Share Posted June 22, 2011 I am using the following query to retrieve the last 20 results of my database, but I need them not to be in descending order. Is there anyway I can accomplish this with the query or do I need to handle it in php? Thanks for your help. SELECT * FROM messages ORDER BY id DESC LIMIT 0,20 Quote Link to comment https://forums.phpfreaks.com/topic/240076-help-reversing-query-results/ Share on other sites More sharing options...
CyberGuru Posted June 22, 2011 Author Share Posted June 22, 2011 I got it sorted it, changed my SQL to the following did the trick. SELECT * FROM (SELECT * FROM tablename ORDER BY tablecolumn DESC LIMIT 5) AS RequiredLimit ORDER BY tablecolumn ASC Quote Link to comment https://forums.phpfreaks.com/topic/240076-help-reversing-query-results/#findComment-1233201 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.