Copying data from one table to another with MYSQL and PHP

Associate
Joined
13 Nov 2003
Posts
1,567
Location
Manchester
Hi All

I need a query that will duplicate all of the values of one table into another.

Basically I am trying to create a master table, that contains all of the contents of six other tables.

I want to know if there is a simply mysql query that will do this, as oppose to having to read all the data out of one table and write it back into another.

Thanks
Aaron
 
Can I suggest looking into getting 'Navicat MySQL'. I've found it to be invaluable when it comes to importing/exporting data between databases and tables.

Its also replaced phpMyAdmin and MySQL Administrator / Query Browser as my favourite general database management tool.
 
append or replace?

Code:
DROP TABLE `table`;
CREATE TABLE `table`(
    SELECT * FROM `table1`;
);

# or:

INSERT INTO `table` VALUES (SELECT * FROM `table1`);
if you have mysql 5+
 
In the end I managed to find this query.

Code:
"INSERT INTO master_list SELECT * FROM mw_temp"

I usually use Mysql Front for managing dbs etc, however this is part of a php app so needed to do it via PHP

Thanks
Aaron
 
can you do SELECT * into NewTable FROM OldTable in MySQL
as this is faster in SQL server than creating the schema and then inserting (because its minimally logged)
 
Back
Top Bottom