-1

I have sets of postcodes range: e.g:

  1. city: kangar, postcode range: >00099 - <02600
  2. city: alor setar, postcode range: > 04999 - <07000 .....

user will key in their address along with postcode, then the system should check the postcode in which range?

issue: I cannot store the postcode with '0' in the front if I used int as data type but if I use string, then I cannot use < @ > @ <= @ >= operation. Do you have any idea on this matter? Thank you in advance.

akayh
  • 15
  • 4

1 Answers1

0

There is no way to store a number as an integer with any leading zeros. You decide the number of leading zeroes when converting the number to text, For example myZipCode.ToString("00000").

However, you should probably read Is it a good idea to use an integer column for storing US ZIP codes in a database. That suggest you should use a string for the postcode, and the same would apply to most other kinds of address.

As AKX mentions, you can still compare strings, it will just use lexographical comparison. But that should not be a problem if you have a fixed number of digits.

JonasH
  • 28,608
  • 2
  • 10
  • 23