doddsey_65 Posted August 9, 2011 Share Posted August 9, 2011 I have a query which pulls profile posts. This query sorts them via the date they were posted DESC. So newest ones are on top. However is a post has a comment i display the comment under the post. but the comments under the post are all ordered by DESC since it is one query to pull all of them. How would I order the comments in the reverse? $sql = "SELECT f.*, u.u_uid, u.u_group_color, u.u_avatar FROM ".TBL_PREFIX."wall_feeds f JOIN ".TBL_PREFIX."users u ON (f.f_poster = u.u_username) WHERE f_uid = '$uid' AND f_pid = '$parent' ORDER BY f_time_posted DESC"; Quote Link to comment Share on other sites More sharing options...
phpSensei Posted August 9, 2011 Share Posted August 9, 2011 I believe you can do something like this, I am not too familiar with this approach but there was a thread like this recently, I will try and find it. ORDER BY f_time_posted DESC, comments ASC"; Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 9, 2011 Share Posted August 9, 2011 It is not clear from your query where the comments are stored - or even if they are included in that query. I would think that the comments would be stored in a separate table with a reference back to the post. Are the posts and comments all stored in the wall_feeds table? If so, please provide the structure. 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.