简体   繁体   中英

Select from one database , insert to another - MySQL

I am trying to basicly copy data from one database to another (just some of them) what i need is to:

  • take data from old database SELECT name, lastname, email, phone FROM codexworld.person WHERE id="544"

  • insert that values to another table INSERT INTO legaljobs.candidates (name, lastname, email, phone) VALUES ( name , lastname, email, phone)

What I did try is:

INSERT INTO legaljobs.candidates (name, lastname, email, phone)
VALUES (SELECT name, lastname, email, phone FROM codexworld.person WHERE id="544")

unfortunately this throw me an error on SQL syntax. Please can somebody advise how can I do this really simple?

Use this query:

INSERT INTO legaljobs.candidates (name, lastname, email, phone)
SELECT name, lastname, email, phone FROM codexworld.person WHERE id="544"

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