470,870 Members | 1,416 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

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='9876543211',fornavn='Ulla',efternavn='Jense n'
where id='5';

This is the error then :

ERROR 1062: Duplicate entry '9876543211' for key 2

I don't get it.

Carl

Jul 20 '05 #1
4 29873
newsfan wrote:
| 2 | 9876543211 | Ulla | Jensen | update patient set cprnr='9876543211',fornavn='Ulla',efternavn='Jense n'
where id='5';

This is the error then :

ERROR 1062: Duplicate entry '9876543211' for key 2


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.
Jul 20 '05 #2
newsfan wrote:
| 2 | 9876543211 | Ulla | Jensen | update patient set cprnr='9876543211',fornavn='Ulla',efternavn='Jense n'
where id='5';

This is the error then :

ERROR 1062: Duplicate entry '9876543211' for key 2


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.
Jul 20 '05 #3

I found out myself thatnks

"newsfan" <fa**********@hotmail.com> wrote in message
news:c7***********@news.cybercity.dk...
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='9876543211',fornavn='Ulla',efternavn='Jense n'
where id='5';

This is the error then :

ERROR 1062: Duplicate entry '9876543211' for key 2

I don't get it.

Carl

Jul 20 '05 #4

I found out myself thatnks

"newsfan" <fa**********@hotmail.com> wrote in message
news:c7***********@news.cybercity.dk...
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='9876543211',fornavn='Ulla',efternavn='Jense n'
where id='5';

This is the error then :

ERROR 1062: Duplicate entry '9876543211' for key 2

I don't get it.

Carl

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Paul | last post: by
reply views Thread by Gary Lundquest | last post: by
1 post views Thread by Gary Lundquest | last post: by
1 post views Thread by Malcolm Dew-Jones | last post: by
5 posts views Thread by baur79 | last post: by
8 posts views Thread by Paul Furman | last post: by
10 posts views Thread by Phil Latio | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.