gpt4 book ai didi

mysql - SQL INSERT INTO 自动放置 ID

转载 作者:行者123 更新时间:2023-11-29 20:42:37 26 4
gpt4 key购买 nike

我只有 50k + SQL 查询,如下所示:

INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(357, 1, '2016-06-03 16:35:24', '2016-06-03 16:35:24', 'SOME CONTENT HERE', 'Artykuły', '', 'trash', 'closed', 'closed', '', 'artykuly__trashed', '', '', '2016-06-03 20:52:06', '2016-06-03 20:52:06', '', 0, '038;p=357', 0, 'autoblog_artykuly', '', 0);

(...)

INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(357, 1, '2016-06-03 16:35:24', '2016-06-03 16:35:24', 'SOME CONTENT HERE', 'Artykuły', '', 'trash', 'closed', 'closed', '', 'artykuly__trashed', '', '', '2016-06-03 20:52:06', '2016-06-03 20:52:06', '', 0, '38;p=357', 0, 'autoblog_artykuly', '', 0);

所有查询都有相同的 ID,当我尝试通过 phpmyadmin 将其添加到数据库时,我得到以下信息:

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

如何更改 ID: 357 来放置自动值?自动递增?

最佳答案

您应该将 ID 设置为 UNIQUEAUTO-INCREMENT并将其从 INSERT 语句中删除。您永远不必担心 ID,它应该由 MySQL 本身处理。

INSERT INTO `wp_posts` (`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(1, '2016-06-03 16:35:24', '2016-06-03 16:35:24', 'SOME CONTENT HERE', 'Artykuły', '', 'trash', 'closed', 'closed', '', 'artykuly__trashed', '', '', '2016-06-03 20:52:06', '2016-06-03 20:52:06', '', 0, '038;p=357', 0, 'autoblog_artykuly', '', 0);

关于mysql - SQL INSERT INTO 自动放置 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38552240/

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