I have a problem when sorting desc / asc by column in a database that sorts it as follows.
9980 91 883 51 507 460 286 243 23 2131
Now I realized that this is because I created colm varchar. In any case, so that it sorts correctly without changing the column to int?
thanks
If you want the elements to be sorted as if they were numbers, cast their integer:
ORDER BY CAST (field AS SIGNED INTEGER)
if you must:
ORDER BY CAST(`YOUR_COL` AS SIGNED)
for DESC
ORDER BY CAST(`YOUR_COL` AS SIGNED) DESC
Source: https://habr.com/ru/post/1391314/More articles:Java Enumerations by Constants - javaProblems implementing polymorphism - c ++I was advised not to use reflection here ... Why not? - javaHow to install PCAP for rubies in Windows - windowsApp_Code and server - c #Unexpected termination of Tomcat - windowsIncrementing behavior in strings - PHP easter egg? - incrementPython WebDriver waiting for page to load - pythonC # Shorten int into case sensitive code - stringhow to encode int with base32 in sql server 2008 - sql-serverAll Articles