简体   繁体   中英

whats wrong with this query?

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

You have the wrong INSERT/SELECT syntax. You don't use "VALUES", just use the 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM