0

I have 2 MySQL databases with similar data. The difference is that one has an email column with about 2000 entries and the other has an email column with no entries. Is there some sort of bulk operation that could be done to copy the 2000 email addresses from database 1 to database 2?

I'm looking for a way to do this with PHP, or better yet, an all-inclusive query to run via phpMyAdmin.

3
  • If it's identical data, why not just copying this table? Commented Apr 14, 2013 at 22:57
  • @Sven Your last name wouldn't be Loth would it? Commented Apr 14, 2013 at 22:58
  • @Sven They are similar tables - not identical. I worded that wrong in the question. Commented Apr 14, 2013 at 23:35

1 Answer 1

4

Something like this:

UPDATE db1.tbl a SET a.email = b.email
JOIN db2.tbl b ON b.id = a.id
Sign up to request clarification or add additional context in comments.

4 Comments

Not extremely familiar with SQL statements - would need more clarity.
As long as both databases are on the same server and have the same user privileges, then you can query off both databases using a single query. This query will update db1's table with db2's e-mails based on the id.
Almost got it...when I run the query, I get a syntax error for the JOIN statement.
@user1710563 Put it in a fiddle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.