Mysql query with 'zero' returns non-zero as well

Hey all!

I have two simple mysql queries (below) that pull zip codes from a row in my DB that is set to varchar. For whatever reason, searches starting with ‘zero’ (ie 02311) also return results with the first number AFTER zero (ie 23116) which then of course displays regions nowhere near close to what the user was looking for. If the table data were numerically formatted I could see how that might affect this, but since it’s varchar it should simply return what I asked for right? Can someone lend some insight into this?


// First - $postalcode is the variable from the actual form
$sql = 'SELECT * FROM tbl_dentists 'WHERE '.$countrycode.$city.$postalcode ORDER BY RAND() LIMIT 30 ';

// Second - This is run if the first query doesn't produce at least 10 records. It'll then pull postal codes +/- 15 from the actual code input in the form.
$postalcode = ' AND den_postalcode < "'.($postal+15).'" AND den_postalcode >"'.($postal-15).'"';
'SELECT * FROM tbl_dentists 'WHERE '.$countrycode.$postalcode ORDER BY RAND() LIMIT 10 ';

Thanks in advance!