Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2017
    Posts
    1

    Question Unanswered: First DB - what datatype for postalcode from CH and DE

    Hi everyone,

    I'm building a DB and I need to put in postalcodes from two different countrys.
    Germany and Switzerland.
    The format is as follows:
    Switzerland has 4 digits starting from 0001 (or so)
    Germany has 5 digits starting from 00001

    I'm struggling with the type here
    For example I would use int(4) for switzerland but germany needs int(5)
    If I put in a zero infront of the Switzerland postalcodes I will have the problem that some of theme are existing in germany for example 04565 could exist in both.

    Can anyone assist me on this?

    Thank you very much!

    Regards,
    T

  2. #2
    Join Date
    Oct 2007
    Posts
    162
    Provided Answers: 9
    Probably better suited for design forum. My first 2 thoughts are a separate table for each or a country code identifier in the table as well.

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,863
    Provided Answers: 17
    Save the data as varchar(5) for two reasons.

    If you are not going to add, subtract, multiply, or take a square root of it, it is not a number.
    If you want the leading 0's preserved, int won't do that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •