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

ep6jt1vc  于 2021-06-21  发布在  Mysql
关注(0)|答案(3)|浏览(333)

我的问题是:

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-您的sql语法有错误;检查与您的mysql服务器版本相对应的手册,在第2行的“select product\u id,serial\u number,pronexo\u code,start\u guard,start\u guar”附近使用正确的语法

有人知道有什么问题吗?我该怎么解决?

i34xakig

i34xakig1#

拆下 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;
0sgqnhkj

0sgqnhkj2#

试试这个:

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
dsekswqp

dsekswqp3#

注意sql语法和字段名键入: VALUE 这里的关键字不正确,请注意 serial_numnber 或者 serial_number 更正字段名的拼写:

insert into unique_products (product_id, SERIAL_NUMBER, 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

有关正确插入select语法的详细信息,请参见此处。

相关问题