Thinkphp queries the time sorting of mysql database data

Source: Internet
Author: User
Thinkphp queries the time sorting problem of mysql database data. the current time has three statuses: The first has expired, and the second has not expired, the third time is to determine the time. what I want to get now is that the unexpired time is before. to ensure that the time is in the middle and the expiration time is before, how should I write the sort statement? $ List & nbsp ;=& nbsp; $ activity-& gt; where ('is _ check Thinkphp query mysql database data time sorting problem
The current time has three states: The first has expired, the second has not expired, and the third is to determine the time. what I want to get now is that the time has not expired, to determine that the time is in the middle and the expiration time is in the middle, how should I write the sort statement?
$ List = $ activity-> where ('is _ check = 1')-> order ('actdate desc')-> limit ($ Page-> firstRow. ','. $ Page-> listRows)-> select ();

The current sorting is only by time desc. due to paging, it is not easy to write. please help. Thank you. Share:
------ Solution --------------------
What is your status field? Assume that the status field is zhuangtai.
In the SQL statement, the order is written as order by zhuangtai desc, and actdate desc is first sorted by status and then (in the same status) by time.

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.