Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将数据从一个数据库中的表复制到wordpress数据库_Php_Mysql_Sql_Database_Wordpress - Fatal编程技术网

Php 将数据从一个数据库中的表复制到wordpress数据库

Php 将数据从一个数据库中的表复制到wordpress数据库,php,mysql,sql,database,wordpress,Php,Mysql,Sql,Database,Wordpress,如何将数据从数据库中的一个表复制到wordpress数据库中?因此,我自己数据库中的表被称为“articles”,我在本地机器上安装了WordPress,它会自动附带表,还有一个名为“wp_posts”的表,我也在这里尝试复制文章。因此,我试图将我创建的网站移至wordpress网站,但我不想丢失所有已创建的文章。我该怎么做?我已经尝试过了,但是我得到了一个SQL语法错误 INSERT INTO wp_seetheuniverse.dbo.wp_posts ('wp_title', 'wp_co

如何将数据从数据库中的一个表复制到wordpress数据库中?因此,我自己数据库中的表被称为“articles”,我在本地机器上安装了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; 

您的表引用包含三个部分。通常,这些部分以这样一个由三部分组成的标识符来描述数据库、模式和表,例如在SQL Server中。但在MySQL模式中,数据库和模式是同义词,所以只有两部分标识符是有效的。我猜,您很可能是从SQLServer的某个示例中复制了这个
dbo

另一件事是永远不要用单引号括住列(或任何其他对象)名称。单引号用于表示字符串文字。因此,除非您想要具有列名的文字字符串值,而不是列的内容,否则不要使用单引号

尝试:


如果一个表的列数多于另一个表,这有关系吗?是的。。如果一个表的列数多于其他表的列数,则不能使用select*。但必须按照相应的顺序选择真正需要的列,并且还必须匹配数据类型。SQL无法选择需要复制的列和不需要的列。。因此,您必须在queryIm中指定仍然收到此错误,错误1064(42000):您的SQL语法中有一个错误;检查与您的MySQL服务器版本对应的手册,以获得使用near'.wp_posts(wp_title,wp_content)的正确语法。从第1行的seetheuniverse.dbo.a'中选择title,content
INSERT INTO wp_seetheuniverse.wp_posts
            (wp_title,
             wp_content)
            SELECT title,
                   content
                   FROM seetheuniverse.articles;