473,395 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 30001
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul | last post by:
This is the currernt table strucure PHP:-------------------------------------------------------------------------------- CREATE TABLE games_developers ( developers_id int(5) NOT NULL...
0
by: Gary Lundquest | last post by:
I have an application with MS Access 2000 as the front end and MySQL as the back end. All was well until I upgraded the MySQL (Linux) server. The Problem: I insert data into a cumulative table....
1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
1
by: Malcolm Dew-Jones | last post by:
Hello I need to detect duplicate errors when using mysql to insert a row in a php program. (I assume that the php version should not make a difference, but I don't know that for sure, which is...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
8
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful...
5
by: baur79 | last post by:
Hi guys i try to run this code in loop and to pass even the entry is duplicated def email_insert_in_db(email): sql="INSERT INTO emails (email) values ('%s') "%(email)...
8
by: Paul Furman | last post by:
How do I turn off MySQL error reporting? I set error_reporting(0); but that doesn't seem to be working.
10
by: Phil Latio | last post by:
I am inserting data into user table which contains 5 fields, sounds simple enough normally but 2 of the fields are designated as UNIQUE. If someone does enter a value which already exists, how do I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.