这个查询有什么问题?

时间:2011-01-17 03:17:11

标签: mysql

INSERT INTO print_development.categories (id, name)
VALUES (select id, name  from print_pro.categories where parent_id is NULL);

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 id, name  from print_pro.categories where parent_id is NULL)' at line 2

1 个答案:

答案 0 :(得分:4)

您的INSERT / SELECT语法错误。您不使用“VALUES”,只需使用SELECT。

INSERT INTO print_development.categories (id, name)
select id, name  from print_pro.categories where parent_id is NULL

http://dev.mysql.com/doc/refman/5.5/en/insert.html