Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the max data using natural sort?

10.12.1 
10.12.10 
10.12.11 
10.12.12 
10.12.13 
10.12.14 
10.12.15 
10.12.16 
10.12.17 
10.12.18 
10.12.19 
10.12.2 
10.12.3 
10.12.4 
10.12.5 
10.12.6 
10.12.7 
10.12.8 
10.12.9 

This is a varchar column. But '10.12.19' is the max data i need. How can i get it?

like image 718
ZA. Avatar asked Feb 11 '26 21:02

ZA.


1 Answers

SQL code

 ORDER BY CAST(SUBSTRING_INDEX(col,'.',-1) AS SIGNED) DESC;
like image 166
ZA. Avatar answered Feb 13 '26 13:02

ZA.