gaza165 Posted December 23, 2008 Share Posted December 23, 2008 i need to use an sql query to select the last 10 from my database but need it in ascending order. $sql = "SELECT * FROM chat ORDER BY chat_id LIMIT 0,10"; i know this will select the records from 0,10 but in my db they are like this id MESSAGE 1 FIRST 2 SECOND 3 THIRD 4 Fifth basically, the older the post i dont want it to be displayed. i want the most recent 10 records that are in the database. sorry i havent explained clearly. Link to comment https://forums.phpfreaks.com/topic/138172-simple-sql-question/ Share on other sites More sharing options...
Yesideez Posted December 23, 2008 Share Posted December 23, 2008 You'll have to read them into an array and reverse the array - only way I can think of doing it. $sql = "SELECT * FROM chat ORDER BY chat_id LIMIT 0,10 DESC"; Link to comment https://forums.phpfreaks.com/topic/138172-simple-sql-question/#findComment-722252 Share on other sites More sharing options...
redarrow Posted December 23, 2008 Share Posted December 23, 2008 Next time use a time stamp in the database. it would of made life so easier. Link to comment https://forums.phpfreaks.com/topic/138172-simple-sql-question/#findComment-722253 Share on other sites More sharing options...
gaza165 Posted December 23, 2008 Author Share Posted December 23, 2008 i am using timestamp in my database, shall i order it by timestamp?? Link to comment https://forums.phpfreaks.com/topic/138172-simple-sql-question/#findComment-722257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.