gpt4 book ai didi

MySQL错误: Duplicate entry for Primary Key

转载 作者:行者123 更新时间:2023-11-29 16:59:05 25 4
gpt4 key购买 nike

SQL查询:

转储表new_recipe

的数据
INSERT INTO `new_recipe` (`id`, `post_title`, `post_image`, `post_author`, `post_date`, `post_desc`) VALUES
(4, 'Daal Chawal', 'DDAa.jpg', 'Asad Khan', '2016-05-29', '\r\n Gujranwala agr pyara na hota\r\n\r\nGulshan Iqbal Park ka nizara na hota\r\n\r\nBypass pr ishara na hota\r\n\r\nSialkoti drwazy ka shara na hota\r\n\r\nPace pr janay ka mode dobara na hota\r\n\r\nBashir k dal chawal ka swad krara na hota\r\n\r\nsb Sattelite Town Girls Collage ka ksoor hai\r\n\r\nw\r\na Gujranwala ka koi larrka aawara na hota("\r\n\r\nGeo Gujranwala'),
(5, 'Daal Makhani', 'maxresdefault.jpg', 'Waqas Ali', '2016-05-29', '\r\n siosadflwq r0ewlk hopxcyfsajr w4dfwsaf654wq13\r\nt1sd3v5sa +et5wq+e f80w+e5t+eqd7fv+6sd1v 3x4c6\r\n5v321d35g 02df6s0+52wer+t q032va0sd')
MySQL said: Documentation

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

这是我的 MYSQL 查询

new_recipe的表结构

CREATE TABLE IF NOT EXISTS new_recipe (
id int(10) NOT NULL,
post_title varchar(250) NOT NULL,
post_image varchar(250) NOT NULL,
post_author varchar(250) NOT NULL,
post_date date NOT NULL,
post_desc text NOT NULL,
PRIMARY KEY (id)
) AUTO_INCREMENT=6 ;

转储表new_recipe

的数据
INSERT INTO `new_recipe` (`id`, `post_title`, `post_image`, `post_author`, `post_date`, `post_desc`) VALUES
(4, 'Daal Chawal', 'DDAa.jpg', 'Asad Khan', '2016-05-29', '\r\n Gujranwala agr pyara na hota\r\n\r\nGulshan Iqbal Park ka nizara na hota\r\n\r\nBypass pr ishara na hota\r\n\r\nSialkoti drwazy ka shara na hota\r\n\r\nPace pr janay ka mode dobara na hota\r\n\r\nBashir k dal chawal ka swad krara na hota\r\n\r\nsb Sattelite Town Girls Collage ka ksoor hai\r\n\r\nw\r\na Gujranwala ka koi larrka aawara na hota("\r\n\r\nGeo Gujranwala'),
(5, 'Daal Makhani', 'maxresdefault.jpg', 'Waqas Ali', '2016-05-29', '\r\n siosadflwq r0ewlk hopxcyfsajr w4dfwsaf654wq13\r\nt1sd3v5sa +et5wq+e f80w+e5t+eqd7fv+6sd1v 3x4c6\r\n5v321d35g 02df6s0+52wer+t q032va0sd');

Image of the PHPmyadmin error `

最佳答案

在第二个转储数据库中,您使用相同的 ID,它已存在于“new_recipe”中,这就是它显示重复条目的原因。

代码:

CREATE TABLE IF NOT EXISTS new_recipe (
id int(10) NOT NULL AUTO INCREMENT,
post_title varchar(250) NOT NULL,
post_image varchar(250) NOT NULL,
post_author varchar(250) NOT NULL,
post_date date NOT NULL,
post_desc text NOT NULL,
PRIMARY KEY (id)
) AUTO_INCREMENT=6 ;

INSERT INTO `new_recipe` (`id`, `post_title`, `post_image`, `post_author`, `post_date`, `post_desc`) VALUES
('', 'Daal Chawal', 'DDAa.jpg', 'Asad Khan', '2016-05-29', '\r\n Gujranwala agr pyara na hota\r\n\r\nGulshan Iqbal Park ka nizara na hota\r\n\r\nBypass pr ishara na hota\r\n\r\nSialkoti drwazy ka shara na hota\r\n\r\nPace pr janay ka mode dobara na hota\r\n\r\nBashir k dal chawal ka swad krara na hota\r\n\r\nsb Sattelite Town Girls Collage ka ksoor hai\r\n\r\nw\r\na Gujranwala ka koi larrka aawara na hota("\r\n\r\nGeo Gujranwala'),
('', 'Daal Makhani', 'maxresdefault.jpg', 'Waqas Ali', '2016-05-29', '\r\n siosadflwq r0ewlk hopxcyfsajr w4dfwsaf654wq13\r\nt1sd3v5sa +et5wq+e f80w+e5t+eqd7fv+6sd1v 3x4c6\r\n5v321d35g 02df6s0+52wer+t q032va0sd');

添加自动增量,在插入数据期间将id清空,它会自动增量。

关于MySQL错误: Duplicate entry for Primary Key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52399024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com