In the forum, there will be different types of posts, such as: General paste, essence, top posts;
These posts in the Forum are sorted according to the different types, not just the type of posts, but also the dynamics of the postings.
Here's a simple sort of post, and we're just looking at the latest dynamic time of the post and the sort of post type.
The latest dynamic time is determined: if you just created a new post, then the latest dynamic time of the posts is the time of creation of the post, if the latest reply, then the latest dynamic time is the latest response time;
Sorting criteria:
1. The latest dynamic time is more new and more forward
2. There is no difference between the general paste and the essence paste in the sort, the top post is definitely the topmost.
In other words, sort the top posts first, and according to the latest dynamic time sort the order between the top posts, and then according to the latest dynamic time to arrange the order of the General post and the essence.
Then we query the database in the collection of posts, according to the SQL statement to query out the sorted data, how to do it?
We're going to use the case of SQL at this point? Then? (When?) Then) ELSE? END.
such as: SELECT * from Topic t WHERE t.forum =? ORDER by (case T.type if 2 then 2 ELSE 0 END) desc, t.lastupdatetime desc;
Different types of stickers in the forum (related to database: Case ...) END)