Posts Post table
Posts_hot Post related Information table
Posts_hot Table ID Association posts table
The hot_top in the Posts_hot table indicates that the post is pinned
The posts_dt_time in the posts table indicates the latest reply time for this post
The problem is: Read the list of posts according to the Forum ID, so that the posts are pinned on top, others sorted by the latest reply time!
Sql
Select p.*,u.*,ph.* from posts p,users u,posts_hot ph where p.forumid= $forumid and p.userid=u.user_id and p.hotid=ph.hot_i D order h.hot_top;
This can only press the top of the front, after adding posts_dt_time on the chaos, there is any way to solve it, I do not want to separate SQL to inquire!
Reply to discussion (solution)
... order h.hot_top desc, h.posts_dt_time desc
You can also query Ah! --The book did not say!!! Thank you.
MySQL ORDER BY