Sort confusion bug articles --mysql

 

As shown in the figure, obviously in descending order of this sort of chaos Why will happen?

The reason: STOREHOUSE_NO this field is stored in the database type is VARCHAR, this type of field, mysql when using the order by query is sorted according to the character, the first character in front of large, and so on, so sort will appear as shown above.

Solution: To get the sort of type int, execute the following sql statement

select es.STOREHOUSE_NO from ERP_STOREHOUSE es order by es.STOREHOUSE_NO+0 desc

 

Guess you like

Origin www.cnblogs.com/zzb-yp/p/11245713.html