S
S
Sergey2016-11-11 11:10:08
MySQL
Sergey, 2016-11-11 11:10:08

How to extract the maximum value from a text field in MySql?

id | value
1 | 3
2 | 24
3 | -5
4 | 2
5 | 2006
| 99
SELECT MAX(value) FROM `test`
Gives 99, but should be 200

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eudj1n, 2016-11-11
@frost18

Try it like this:
SELECT MAX(CAST(value AS UNSIGNED)) FROM `test`

R
Rsa97, 2016-11-11
@Rsa97

200 > 99
'99' > '200'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question