Jump to content

Copying row from one table to another (and one database to another


blakekr

Recommended Posts

Okay, I understand the idea of the "insert into... select..." statement,

and the idea of the mysql_select_db function ...

but I still can't figure out how to take a few rows in table Foo in database A and copy them into table Foo in database B.

Your help appreciated!
Link to comment
Share on other sites

So say your selected database is A (mysql_select_db('A',$conn)).
If the databases are on the same server, it's pretty easy:
INSERT INTO b.foo ...
or from "B":
INSERT INTO foo ... SELECT * FROM a.foo

If the db's are on different servers, you'll have to use PHP to establish a connection to both and extract and insert the data manually.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.