ERROR 1062: Duplicate entry for key 2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • newsfan

    ERROR 1062: Duplicate entry for key 2

    I get that error when I try to update a table in my database

    This is my table
    +----+------------+---------+-----------+
    | ID | CPRNR | NAME | SURNAME |
    +----+------------+---------+-----------+
    | 1 | 1234567890 | Ole | Hansson |
    | 2 | 9876543211 | Ulla | Jensen |
    | 3 | 1234321234 | Ole | Olsson |
    | 4 | 7654321234 | Petter | ?es |
    | 5 | 9876543213 | Ulla | Jensen |
    +----+------------+---------+-----------+
    5 rows in set (0.00 sec)

    And my update lools like this:

    update patient set cprnr='98765432 11',fornavn='Ul la',efternavn=' Jensen'
    where id='5';

    This is the error then :

    ERROR 1062: Duplicate entry '9876543211' for key 2

    I don't get it.

    Carl



  • Aggro

    #2
    Re: ERROR 1062: Duplicate entry for key 2

    newsfan wrote:
    [color=blue]
    > | 2 | 9876543211 | Ulla | Jensen |[/color]
    [color=blue]
    > update patient set cprnr='98765432 11',fornavn='Ul la',efternavn=' Jensen'
    > where id='5';
    >
    > This is the error then :
    >
    > ERROR 1062: Duplicate entry '9876543211' for key 2[/color]

    You have:
    9876543211 in your table where id is 2 (like the error says)

    And you try to insert this value:
    9876543211 to your table, where id is 5

    Looks like you have unique/key/etc. fieldtype for CPRNR which prevents
    you from giving same value twice.

    Comment

    • Aggro

      #3
      Re: ERROR 1062: Duplicate entry for key 2

      newsfan wrote:
      [color=blue]
      > | 2 | 9876543211 | Ulla | Jensen |[/color]
      [color=blue]
      > update patient set cprnr='98765432 11',fornavn='Ul la',efternavn=' Jensen'
      > where id='5';
      >
      > This is the error then :
      >
      > ERROR 1062: Duplicate entry '9876543211' for key 2[/color]

      You have:
      9876543211 in your table where id is 2 (like the error says)

      And you try to insert this value:
      9876543211 to your table, where id is 5

      Looks like you have unique/key/etc. fieldtype for CPRNR which prevents
      you from giving same value twice.

      Comment

      • newsfan

        #4
        Re: ERROR 1062: Duplicate entry for key 2


        I found out myself thatnks

        "newsfan" <farmer_joe41@h otmail.com> wrote in message
        news:c7opdc$2a0 s$1@news.cyberc ity.dk...[color=blue]
        > I get that error when I try to update a table in my database
        >
        > This is my table
        > +----+------------+---------+-----------+
        > | ID | CPRNR | NAME | SURNAME |
        > +----+------------+---------+-----------+
        > | 1 | 1234567890 | Ole | Hansson |
        > | 2 | 9876543211 | Ulla | Jensen |
        > | 3 | 1234321234 | Ole | Olsson |
        > | 4 | 7654321234 | Petter | ?es |
        > | 5 | 9876543213 | Ulla | Jensen |
        > +----+------------+---------+-----------+
        > 5 rows in set (0.00 sec)
        >
        > And my update lools like this:
        >
        > update patient set cprnr='98765432 11',fornavn='Ul la',efternavn=' Jensen'
        > where id='5';
        >
        > This is the error then :
        >
        > ERROR 1062: Duplicate entry '9876543211' for key 2
        >
        > I don't get it.
        >
        > Carl
        >
        >
        >[/color]


        Comment

        • newsfan

          #5
          Re: ERROR 1062: Duplicate entry for key 2


          I found out myself thatnks

          "newsfan" <farmer_joe41@h otmail.com> wrote in message
          news:c7opdc$2a0 s$1@news.cyberc ity.dk...[color=blue]
          > I get that error when I try to update a table in my database
          >
          > This is my table
          > +----+------------+---------+-----------+
          > | ID | CPRNR | NAME | SURNAME |
          > +----+------------+---------+-----------+
          > | 1 | 1234567890 | Ole | Hansson |
          > | 2 | 9876543211 | Ulla | Jensen |
          > | 3 | 1234321234 | Ole | Olsson |
          > | 4 | 7654321234 | Petter | ?es |
          > | 5 | 9876543213 | Ulla | Jensen |
          > +----+------------+---------+-----------+
          > 5 rows in set (0.00 sec)
          >
          > And my update lools like this:
          >
          > update patient set cprnr='98765432 11',fornavn='Ul la',efternavn=' Jensen'
          > where id='5';
          >
          > This is the error then :
          >
          > ERROR 1062: Duplicate entry '9876543211' for key 2
          >
          > I don't get it.
          >
          > Carl
          >
          >
          >[/color]


          Comment

          Working...