Different types of stickers in the forum (related to database: Case ...) END)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.