DirectTech
DirectTech

Reputation: 49

How can I move a specific set of user data from one MySQL database to another with PHP?

I have two MySQL databases with similar sets of data, both on the same server. I need to grab select fields from a given table in database X and move them into given fields of a table in database Y. The table names are different, but field names are the same except for a prefix on database Y.

The database should be moved based on a unique username that exists on both ends. So I would get the data for username A, then find username A in database Y, and copy the data from the select fields for that user.

Any direction or advice would be much appreciated. This by the way would be a process to run as needed, not something that needs to continuously run. Using PHP 5.3 and MySQL 5.

Upvotes: 0

Views: 185

Answers (1)

Dan Sharpe
Dan Sharpe

Reputation: 159

INSERT INTO database1.customer (
  id
  fname,
  etc
) 
SELECT 
  id
  fname,
  etc
FROM
  database2.customer 

Upvotes: 2

Related Questions