MySQL - copy a table into another table - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-20-2005, 06:00 PM   #1 (permalink)
Junior Member
 
Join Date: Jul 2005
Posts: 28
Default MySQL - copy a table into another table

Hello,

Don't ask why but I need to figure out how to use INSERT INTO to copy an entire table into another? I think it is possible but not sure of the syntax or command.

thanks
tiffn is offline   Reply With Quote
Sponsored Links
Old 12-21-2005, 06:51 PM   #2 (permalink)
Regular User
 
Join Date: Jul 2005
Posts: 43
Default

If the tables share the same structure (same number of columns, each matching pair of columns with the same datatype), then the syntax is really simple --

insert
into table2
select *
from table1
If the tables do not share the same structure, then you must name the columns of the table you are inserting into, and provide an expression for each of them in the subselect --

insert
into table2
( col1
, col2
, col3 )
select field3
, ( field7 + field8 ) * 9.37
, 0
from table1

INSERT INTO is great because of this ability to reformat data as part of the insertion process.
sandman is offline   Reply With Quote
Old 01-24-2010, 09:31 AM   #3 (permalink)
Junior Member
 
Join Date: Oct 2009
Posts: 6
Default Re: MySQL - copy a table into another table

Table to Another ... means we copy one table to a different table but it contains ... copy the table you need to establish the connection with the MySQL ...







________________
Download Microsoft 2010
Bob Willis is offline   Reply With Quote
Old 01-26-2010, 03:26 AM   #4 (permalink)
Junior Member
 
Join Date: Jan 2010
Posts: 5
Default Re: MySQL - copy a table into another table

Well there are Several ways,
- Between two not identical Tables
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE _if_any_condition_applying;

- Between two identical Tables
insert into TableName1
Select * from TableName2


yasas177 is offline   Reply With Quote
Old 02-04-2010, 04:13 PM   #5 (permalink)
Regular User
 
Join Date: Jan 2010
Posts: 23
Default Re: MySQL - copy a table into another table

Quote:
Originally Posted by tiffn View Post
Don't ask why but I need to figure out how to use INSERT INTO to copy an entire table into another? I think it is possible but not sure of the syntax or command.
There is much easier way to do it. In fact you can copy the entire database from one server to another with DataPro - dataPro | Database software | Database conversion | Data Migration
nice123 is offline   Reply With Quote
Old 03-22-2010, 06:20 AM   #6 (permalink)
Junior Member
 
Join Date: Mar 2010
Posts: 58
Default Re: MySQL - copy a table into another table

Was the forum designed by yourself? it is so likeable!
mings is offline   Reply With Quote
Old 06-14-2010, 05:48 AM   #7 (permalink)
Junior Member
 
Join Date: Jun 2010
Posts: 10
Default Re: MySQL - copy a table into another table

well........................m quite confused will tell u later
yanejarker is offline   Reply With Quote
Old 06-16-2010, 07:22 PM   #8 (permalink)
Junior Member
 
Join Date: Jan 2010
Posts: 29
Default Re: MySQL - copy a table into another table

Quote:
Originally Posted by sandman View Post
If the tables share the same structure (same number of columns, each matching pair of columns with the same datatype), then the syntax is really simple --

insert
into table2
select *
from table1
If the tables do not share the same structure, then you must name the columns of the table you are inserting into, and provide an expression for each of them in the subselect --

insert
into table2
( col1
, col2
, col3 )
select field3
, ( field7 + field8 ) * 9.37
, 0
from table1

INSERT INTO is great because of this ability to reformat data as part of the insertion process.

In addition, you should do some connection between the tables before doing this syntax.

Thanks
staceybrown281 is offline   Reply With Quote
Old 07-13-2010, 07:14 AM   #9 (permalink)
Junior Member
 
annawu's Avatar
 
Join Date: Jul 2010
Posts: 11
Default Re: MySQL - copy a table into another table

It is great! I love them very much!
annawu is offline   Reply With Quote
Old 07-16-2010, 09:59 AM   #10 (permalink)
Junior Member
 
Join Date: Jul 2010
Location: UK
Posts: 71
Send a message via AIM to football_tickets Send a message via Yahoo to football_tickets Send a message via Skype™ to football_tickets
Default Re: MySQL - copy a table into another table

that is so important information for me thanks for the share


_________________
Football Tickets | Arsenal Tickets | Chesela Tickets | Football Blog
football_tickets is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 10:32 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting