Jump to content

Archived

This topic is now archived and is closed to further replies.

whitemoss

problem when insert data into table

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.