我试图将数据从一个数据库基本复制到另一个数据库(只是其中一些)我需要的是:
从旧数据库SELECT name, lastname, email, phone FROM codexworld.person WHERE id="544"
将该值插入另一个表INSERT INTO legaljobs.candidates (name, lastname, email, phone) VALUES ( name , lastname, email, phone)
我尝试的是:
INSERT INTO legaljobs.candidates (name, lastname, email, phone)
VALUES (SELECT name, lastname, email, phone FROM codexworld.person WHERE id="544")
不幸的是,这给我一个SQL语法错误。请有人建议我怎么能这么简单?
答案 0 :(得分:2)
使用此查询:
INSERT INTO legaljobs.candidates (name, lastname, email, phone)
SELECT name, lastname, email, phone FROM codexworld.person WHERE id="544"