I have a set field in my db that is longtext. I have used prices in this field and cannot change the field type to integer. In my query however I need to sort by these fields and assume I should treat them as an integer. is there another way to query these results to sort by price as an integer and not longtext without having to change the field type? at the moment 3900000 is smaller than 4300 in my result set.
A:
If all your fields are castable to an integer, you can just use this:
SELECT *
FROM mytable
ORDER BY
myfield + 0
Quassnoi
2010-05-26 09:45:20