whitemoss Posted February 14, 2006 Share Posted February 14, 2006 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 1My 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. Quote Link to comment https://forums.phpfreaks.com/topic/3417-problem-when-insert-data-into-table/ Share on other sites More sharing options...
wickning1 Posted February 14, 2006 Share Posted February 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/3417-problem-when-insert-data-into-table/#findComment-11680 Share on other sites More sharing options...
whitemoss Posted February 14, 2006 Author Share Posted February 14, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/3417-problem-when-insert-data-into-table/#findComment-11681 Share on other sites More sharing options...
fenway Posted February 14, 2006 Share Posted February 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/3417-problem-when-insert-data-into-table/#findComment-11721 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.