The sorting problem in PHP + Mysql is that the table in the database has three fields: periodType, tinyint type, storage cycle type, indicating daily, weekly, every month is periodData, tinyint type, storage cycle data, if it is daily, is empty, every PHP + Mysql sorting problem
In this case, the table in the database has three fields:
PeriodType, tinyint type, storage cycle type, indicating daily, weekly, and monthly
One is periodData, tinyint type, the data stored in the cycle, if it is daily, is empty, every week, range in 1-7, monthly, range in 1-31
There is also a time, time type, storage time
I want to read them, calculate the latest date corresponding to each column, and sort them by date. I wonder if I can implement it at the Mysqli level? Can I only read all of them, use PHP for calculation, and sort them again? Is there any other solution? The database structure can be changed, not necessarily.
------ Solution --------------------
Calculate the latest date corresponding to each column, and then sort by date
How can I explain this sentence?
It is best to post your:
Create table .......
Insert into table .......
And the result + simple description.
------ Solution --------------------
SQL --> SELECT * from tableName order by colTime desc limit 10;
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