Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.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
Mysql 将表a中的多个ID插入表b_Mysql_Sql_Insert - Fatal编程技术网

Mysql 将表a中的多个ID插入表b

Mysql 将表a中的多个ID插入表b,mysql,sql,insert,Mysql,Sql,Insert,我想从现有表中选择所有ID,并以这种方式将它们插入新创建的表中: INSERT INTO product_extend (product_id) VALUES (SELECT product_id FROM products) 为每个id创建一个新行。有人能告诉我怎么做吗?像这样: INSERT INTO product_extend (product_id) SELECT product_id FROM products; 正如MySQL手册中所述。通过这个查询,您得到了什么?

我想从现有表中选择所有ID,并以这种方式将它们插入新创建的表中:

INSERT INTO product_extend (product_id) VALUES (SELECT product_id FROM products)
为每个id创建一个新行。有人能告诉我怎么做吗?

像这样:

INSERT INTO product_extend (product_id) 
SELECT product_id FROM products;

正如MySQL手册中所述。

通过这个查询,您得到了什么?