mike1313 Posted November 26, 2007 Share Posted November 26, 2007 How would I properly use ORDER By in this statement? $sql = "SELECT message_id, user_name, message, date_format(post_time, '%h:%i') as post_time" . " FROM message WHERE cn_id = " . db_input($_GET['cn']) . " AND message_id > " . $last; Link to comment https://forums.phpfreaks.com/topic/78971-help-with-a-query/ Share on other sites More sharing options...
xyn Posted November 26, 2007 Share Posted November 26, 2007 Can you explain more about your "order" try explaining it a bit more of what you are trying to do. Link to comment https://forums.phpfreaks.com/topic/78971-help-with-a-query/#findComment-399630 Share on other sites More sharing options...
mike1313 Posted November 26, 2007 Author Share Posted November 26, 2007 I want to display the last 20 rows and ORDER BY message_id how would I do this? Link to comment https://forums.phpfreaks.com/topic/78971-help-with-a-query/#findComment-399634 Share on other sites More sharing options...
xyn Posted November 26, 2007 Share Posted November 26, 2007 mysql_query("select * from `table` ORDER BY `message_id` DESC Limit 0,20") Link to comment https://forums.phpfreaks.com/topic/78971-help-with-a-query/#findComment-399637 Share on other sites More sharing options...
mike1313 Posted November 26, 2007 Author Share Posted November 26, 2007 I know that much but I want to change as little as possible in my current statement. Link to comment https://forums.phpfreaks.com/topic/78971-help-with-a-query/#findComment-399639 Share on other sites More sharing options...
xyn Posted November 26, 2007 Share Posted November 26, 2007 ORDER BY `message_id` DESC Limit 0,20 use that at the end of your query then... Link to comment https://forums.phpfreaks.com/topic/78971-help-with-a-query/#findComment-399642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.