samedi 18 juin 2016

Database ERROR:Duplicate entry '1-0' for key 'PRIMARY'

what can I do for this problem. I got the error message:

Database ERROR:Database ERROR:Duplicate entry '1-0' for key 'PRIMARY'

any help would be much appreciated, thanks.

This is the table:

 $sql = "CREATE TEMPORARY TABLE incidentlog_temp (
                      incidentid int(10) unsigned NOT NULL,
                      sidgroup tinyint(4) NOT NULL default '0',
                      sid int(10) unsigned,
                      incidentdate datetime,
                      incidenttypeid smallint(5) unsigned,
                      count int(10) unsigned,
                      PRIMARY KEY  (incidentid,sidgroup),
                      KEY idx_incidentdate (incidentdate),
                      KEY idx_incidenttypeid (incidenttypeid)
                    )";

and this is the INSERT INTO query:

 $sql = "INSERT INTO incidentlog_temp
                            SELECT incidentid, sidgroup, sid, incidentdate, incidenttypeid, count FROM incidentlog
                            WHERE incidentdate>="".date("Y-m-d", $startdate)." 00:00:00" AND incidentdate<="".$enddate.""
                            AND incidenttypeid>0 AND protocol IS NOT NULL";

here is my incidentlog table:

+----------------+----------------------+------+-----+---------------------+----------------+
| Field          | Type                 | Null | Key | Default             | Extra          |
+----------------+----------------------+------+-----+---------------------+----------------+
| incidentid     | int(10) unsigned     | NO   | PRI | NULL                | auto_increment |
| sidgroup       | tinyint(4)           | NO   | PRI | 0                   |                |
| sid            | int(10) unsigned     | YES  |     | NULL                |                |
| createdate     | datetime             | NO   |     | 0000-00-00 00:00:00 |                |
| createby       | smallint(5) unsigned | YES  |     | NULL                |                |
| updatedate     | datetime             | NO   |     | 0000-00-00 00:00:00 |                |
| updateby       | smallint(5) unsigned | YES  |     | NULL                |                |
| qadate         | datetime             | NO   |     | 0000-00-00 00:00:00 |                |
| qaby           | smallint(5) unsigned | YES  |     | NULL                |                |
| incidentdate   | datetime             | YES  | MUL | NULL                |                |
| enddatetime    | datetime             | YES  |     | NULL                |                |
| incidenttypeid | smallint(5) unsigned | YES  | MUL | NULL                |                |
| count          | int(10) unsigned     | YES  |     | NULL                |                |
| port           | int(11) unsigned     | YES  | MUL | NULL                |                |
| protocol       | int(11) unsigned     | YES  | MUL | NULL                |                |
| addinfo        | text                 | YES  |     | NULL                |                |
| analystcomment | text                 | YES  |     | NULL                |                |
+----------------+----------------------+------+-----+---------------------+----------------+

Aucun commentaire:

Enregistrer un commentaire