Jump to content

problem when insert data into table


whitemoss

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.
Link to comment
https://forums.phpfreaks.com/topic/3417-problem-when-insert-data-into-table/
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.
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

Archived

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

×
×
  • Create New...

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.