MySQL - 如何使用 select 语句插入多行?

标签 mysql sql

这是我的查询:

insert into unique_products values (product_id, serial_numnber, pronexo_code, entry_time, exit_time, guarantee_long, expanded_guarantee_long)
select product_id, serial_number, pronexo_code, start_guarantee_date, start_guarantee_date, guarantee_long, expanded_guarantee_long
from table_24

它抛出这个错误信息:

#1064 - 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 'select product_id, serial_number, pronexo_code, start_guarantee_date, start_guar' at line 2

有人知道问题出在哪里吗?我该如何解决?

最佳答案

从您的查询中删除 VALUES 关键字。

试试这个:

INSERT INTO unique_products (product_id, serial_numnber, pronexo_code, entry_time, exit_time, guarantee_long, expanded_guarantee_long)
SELECT product_id, serial_number, pronexo_code, start_guarantee_date, start_guarantee_date, guarantee_long, expanded_guarantee_long
FROM table_24;

关于MySQL - 如何使用 select 语句插入多行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49727641/

相关文章:

php - 在一行中添加一个新值,与旧值相邻,并用逗号分隔

mysql - 重写不带with子句的sql

MySQL/Spring : Cannot delete or update a parent row a foreign key constraint fails

php - 控制不进入PHP类文件

mysql - 如何在动态消息中选择我或我的 friend 创建的帖子?

具有特定数字范围的 SQL UPDATE 表行范围

sql - Firebird:更改 "anonymous"外键

单击保存图标时 MySQL Workbench 崩溃

javascript - 如何从我的外部 javascript 文件访问 php 变量

php - 使 PHP 在提交表单后运行,而不重定向到另一个 PHP 页面来处理数据