I have some prices in a MySQL db, written like:
19900
29900
30000
28900
etc.
How can I compare these as numbers, so I can use MIN (price) correctly in my SELECT queries?
I have found MySql: Compare 2 strings which are numbers?, but it looks like I can't nest the MIN and the CAST correctly.
You can find the link helpful
Try this sql fiddle!
or try this:
SELECT min(CONVERT(price,UNSIGNED INTEGER)) AS num
FROM sample