php - 将数据从一个数据库中的表复制到 wordpress 数据库
问题描述
如何将数据库中的一个表中的数据复制到 wordpress 数据库中?所以我自己的数据库中的表被称为“文章”,我已经在我的本地机器上安装了 WordPress,它自动附带了表,还有一个名为“wp_posts”的表,我也试图在其中复制文章。所以我正在尝试将我创建的其他网站移动到 wordpress 网站,但我不想丢失所有已经创建的文章。我该怎么做?我已经尝试过了,但我得到了一个 SQL 语法错误。
INSERT INTO wp_seetheuniverse.dbo.wp_posts ('wp_title', 'wp_content')
SELECT 'title', 'content' FROM seetheuniverse.dbo.articles;
这是我得到的错误
ERROR 1064 (42000): 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 '.wp_posts ('wp_title', 'wp_content') SELECT
'title', 'content' FROM seetheuniver' at line 1
解决方案
确保在 INTO 和 select 子句中有相应的列(数字和类型)
INSERT INTO wp_seetheuniverse.dbo.wp_posts (col1, col2, col3)
SELECT your_col1, your_col, your_col3
FROM seetheuniverse.dbo.articles;
不要在列名周围使用单引号,最终我们将反引号用于复合列名或保留字
INSERT INTO wp_seetheuniverse.wp_posts (wp_title, wp_content)
SELECT title, content FROM seetheuniverse.articles;
并确保您使用的是正确的 database.schema.table 参考
INSERT INTO dbo.wp_seetheuniverse.wp_posts (wp_title, wp_content)
SELECT title, content FROM dbo.seetheuniverse.articles;
推荐阅读
- swift - 使用未声明的类型“DynamicLink”
- r - 我的 100000 x 200 数据矩阵如何转换为图像?
- java - Apache Arrow Plasma 客户端 - 无法连接到内存存储(UnsatisfiedLinkError)
- python - 在 Django 中建模用户到用户的连接
- python - 无法在 Python 中执行点
- python - 蟒蛇特质。在完成按钮触发之前更新属性
- javascript - javascript更新类时使用requestanimationframe有用吗?
- java - 在java中遍历tar.gz
- bash - Shell 循环只返回一个文件
- excel - 如何停止浏览器