I would like to compare two strings as numbers in MySQL. I have the following data in my table:
0,15 kg
0,52 kg
0,68 kg
1,24 kg
Now I would like to compare a string with that data. What I tried is this:
SELECT * FROM `foobar` WHERE weight+0.0 <= '0,7 kg'
Since MySQL seems not to understand the comma as a decimal separator I tried replacing it with a dot:
SELECT * FROM `foobar` WHERE REPLACE(weight+0.0,',','.') <= REPLACE('0,7 kg',',','.')
However I always get weird results including numbers that are larger than 0.7. Oddly when I try ordering the weight column the ordering is correct!