I have a table mapping postal code ranges to contacts. Postal codes are saved in multiple formats for different countries.
Table postcode-range:
FROM-CODE TO-CODE CONTACT-ID COUNTRY-CODE 12000 12999 18 fr BT000000 BT9ZZZZZ 34 uk ...
To find a contact in a specific range , e.g. range starting with 123, I use the following query:
select * from postcode-range
where '123' between from-code and to-code
and country-code = 'fr'
This will return the first entry, contact-id 18.
The problem is if I search for '120' or '12' I get no results.
Any idea what's wrong here? Anybody got an alternative SQL query?