Php reads data from the post table for sorting

Source: Internet
Author: User
Php reads data from the post table for sorting. the posts Post table posts_hot Post-related information table posts_hot table ID is associated with the hot_top in the Posts table posts_hot table, which indicates that posts_dt_time in the posts table is the latest post. the reply time problem is that php reads data from the post table for sorting.
Posts Post table
Posts_hot Post information table
Posts_hot table ID is associated with the Posts table
The hot_top in the posts_hot table indicates that the Post is set to the top.
Posts_dt_time in the posts table indicates the latest reply time of the post.
The problem is: read the post list based on the forum ID, so that the posts are placed at the top, and the others are 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_id order h. hot_top;
In this way, you can only press the top button to the front, and adding posts_dt_time to the back will be messy. Is there any solution? I don't want to separate the SQL to query it!
Share: More

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.