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!
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.