B-219 Sec-55 Noida, India
+918010221733

How to get maximum value of a varchar field having text followed by integer in mysql

For eg you have below given table “Records”

ID      Name
1 test1
2 test2
3 test3
4 test4

If you want to fetch maximum value of ‘Name’ run the below given query

SELECT max(CAST(substring(`Name`,5) as UNSIGNED)) as maximum  FROM `Records`

(Visited 79 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.