For sorting of mysql string fields, I have A varchar type field. There are three pieces of data in the order by a desc, the order is as follows: 2013.03, 2013.02, 2013.04
How can I keep the latest time at the top? Without modifying the field type of a data table.
Reply to discussion (solution)
Assume that the 2013.03 field is shijian.
Order by a desc, shijian desc
Order by can have multiple fields
Assume that the 2013.03 field is shijian.
Order by a desc, shijian desc
Order by can have multiple fields
The key is that the 2013.03 field is.
I tried it in the following order according to your requirements... I don't know why you can't get the same result...
I tried it in the following order according to your requirements... I don't know why you can't get the same result...
Is your field type varchar?
Yes varchar
I tried it in the following order according to your requirements... I don't know why you can't get the same result...
When you say this, I will go back and look at it again. Ah, I found that the data is sorted again normally. I don't even know why. It's too bad.
For the sake of insurance, I finally split it into two fields. One is used to save the year, and the other is used to save the month, which is an integer. Ranking is more reliable.
I still don't understand. the sorting is not normal today. I have been thinking about it for a long time and it will be normal again in the evening. Evil.