Jump to content


Photo

problem when insert data into table


  • Please log in to reply
3 replies to this topic

#1 whitemoss

whitemoss
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 February 2006 - 02:32 AM

Hi All,

I tried to insert a data into a table but it didnt work. The error is: ERROR 1062: Duplicate entry '868648' for key 1

My table structure is:

mysql> desc mohelp;
+--------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------------+------+-----+---------+----------------+
| RecordID | int(10) unsigned | | PRI | NULL | auto_increment |
| DateInsert | datetime | YES | | NULL | |
| DateSend | datetime | YES | MUL | NULL | |
| MONumber | varchar(20) | YES | | NULL | |
| MobileNumber | varchar(20) | YES | MUL | NULL | |
| Message | varchar(225) | YES | | NULL | |
| Status | tinyint(1) | YES | | 0 | |
| TransID | varchar(20) | YES | | NULL | |
+--------------+------------------+------+-----+---------+----------------+


Hope anyone can help me regarding this matter.

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 14 February 2006 - 04:10 AM

It looks like you're trying to insert data with RecordID set to '868648', but another row in the table already has that id. If a column is set as the primary key then you may not have two rows with that column set to '868648'.

It is set to AUTO_INCREMENT so you shouldn't be trying to insert anything into that column.

#3 whitemoss

whitemoss
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 February 2006 - 04:24 AM

I dunt insert any value for RecordID since it was an auto_increment but I still get the error.Below is my insert query.


insert into mohelp(DateInsert,DateSend,MONumber,MobileNumber,Message,Status,TransID) values ('2005-02-14 10:07:56','2005-02-14 10:07:56
','28882','0192426699','Help',1,'987654');
ERROR 1062: Duplicate entry '868648' for key 1


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 14 February 2006 - 08:32 PM

Doesn't have to be the primary key, just any unique key -- there are two other columns with "MUL" in the description, and either of these (DateSend or MobileNumber) could be it. My guess would be the latter.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users