[MySQL] #1062 - Duplicate entry '1' for key 'PRIMARY' Help me!
#1

SQL sorgusu:

--
-- Tablo dцkьm verisi `aracanahtarlar`
--
INSERT INTO `aracanahtarlar` ( `SiraNo` , `AracID` , `SQLID` )
VALUES ( 1, 1, 2014 ) , ( 2, 1, 2013 ) , ( 3, 1, 2015 ) , ( 4, 1, 2012 ) ;



MySQL зıktısı:

#1062 - Duplicate entry '1' for key 'PRIMARY'

Help me please.
Reply
#2

In the column you must put something like: "`Key` INTEGER PRIMARY KEY AUTOINCREMENT"
And you must not set it
Reply
#3

You have probably defined 'AracID' as primary key. Could you please paste the definition of the table?
Reply
#4

-- Tablo iзin tablo yapısı `aracanahtarlar`
--

CREATE TABLE IF NOT EXISTS `aracanahtarlar` (
`SiraNo` int(11) NOT NULL AUTO_INCREMENT,
`AracID` int(11) NOT NULL,
`SQLID` int(11) NOT NULL,
PRIMARY KEY (`SiraNo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Tablo dцkьm verisi `aracanahtarlar`
--

INSERT INTO `aracanahtarlar` (`SiraNo`, `AracID`, `SQLID`) VALUES
(1, 1, 2014),
(2, 1, 2013),
(3, 1, 2015),
(4, 1, 2012);

Table of this, as well as my english is a little bad because I'm Turkish. I'd appreciate if you type a more descriptive.
Reply
#5

Try this:
pawn Код:
CREATE TABLE IF NOT EXISTS `aracanahtarlar` (
`SiraNo`INTEGER PRIMARY KEY AUTOINCREMENT,
`AracID` int(11) NOT NULL,
`SQLID` int(11) NOT NULL,
PRIMARY KEY (`SiraNo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
And you must not set it:
pawn Код:
INSERT INTO `aracanahtarlar` (`AracID`, `SQLID`) VALUES
(1, 2014),
(1, 2013),
(1, 2015),
(1, 2012);
It will auto-increase..
Reply
#6

Like you said, another error comes when you have made.

Quote:

SQL sorgusu:

--
-- Veritabanı: `newyorkrpg`
--
-- --------------------------------------------------------
--
-- Tablo iзin tablo yapısı `aracanahtarlar`
--
CREATE TABLE IF NOT EXISTS `aracanahtarlar` (

`SiraNo` INTEGER PRIMARY KEY AUTOINCREMENT,
`AracID` int( 11 ) NOT NULL ,
`SQLID` int( 11 ) NOT NULL ,
PRIMARY KEY ( `SiraNo` ) ) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =5;



MySQL зıktısı:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTOINCREMENT,
`AracID` int(11) NOT NULL,
`SQLID` int(11) NOT NULL,
PRIMARY KEY ' at line 12

Reply
#7

pawn Код:
CREATE TABLE IF NOT EXISTS `aracanahtarlar` (

`SiraNo` INTEGER AUTO_INCREMENT,
`AracID` int( 11 ) NOT NULL ,
`SQLID` int( 11 ) NOT NULL ,
PRIMARY KEY ( `SiraNo` ) ) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT =5
Try that
Reply
#8

Problem fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)