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.