how to convert varchar to int in query in mysql
CONVERT and CAST were added in mysql 4.0.2, but you might not need them, try just using the varchar as a number and see if mysql converts it for you:
http://www.mysql.com/doc/C/a/Cast_Functions.html