PHP reads data from the Post table to sort the problem

Source: Internet
Author: User
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

  • 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.