mekha Posted September 19, 2012 Share Posted September 19, 2012 i have 2 tables:1) father table.. (posts table)2)child table.. (comments table)now i ordered the results by (id of father) desc.....now what i want is if comment on some post,,,this post is being the first in the order!..any help please ?what query to use? Link to comment Share on other sites More sharing options...
Ingolme Posted September 19, 2012 Share Posted September 19, 2012 Hmm... You would need to join the tables. I think something like this might work: SELECT posts.field1, posts.field2 FROM posts, comment WHERE comment.parent = post.id ORDER BY comment.date Link to comment Share on other sites More sharing options...
mekha Posted September 19, 2012 Author Share Posted September 19, 2012 Sorry man ... not 2 tables...comments and posts in the same table...the post:parent_id = 0 / the comment:parent_id = $postid .... any another suggestions ? Link to comment Share on other sites More sharing options...
mekha Posted September 19, 2012 Author Share Posted September 19, 2012 mmm ok... i solved it....i created another date field in the table...and when adding a comment...update the date of post field to the same of the comment and order by this field ...thank you man Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.