Can we extract max value using regexp_substr in mysql?

I get a dynamic string with values separated by comma. Need to extract max value using regexp_substr.

e.g “55,222,3,4000,10” I need to extract 4000 in the above case using regex in MySQL.

Must it be done via regex in mysql?
It would be simple in PHP

$max = max(explode(',', $array));

It must be done using MySql.

Step 1: Design your database better.
Step 2: SELECT MAX().

Txs for the reply. I can’t. I am using SAAS system.

“It must be done using MySQL”, “I cant change the database”… I suggest you send an email to the SAAS support team asking them how to do it then, because this is a ridiculous setup. It’s the exact reason why you DONT store data this way.

For starters, Is that 5 numbers, or 4? Is it 55 and 222, or 55,222? Is it 4000 and 10, or 4000.10? How can you tell? Why does the system store numbers with a delimiter that is used as a thousands separator in the US, and a decimal separator in many other countries?

Hey
Just to answer your question. There will always be 5 numbers separated by comma.
e.g

“55,222,3,4000,10”
First Number: 55
Second Number: 222
Third Number: 3
Four Number: 4000
Five Number: 10