473,394 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to Copy Table1 to Table2 ?

I have 2 tables in a database:

As an example, let's say Table1 has 20 rows, like this:

Table1:
CategoryNumber CategoryName
1000 Radios
1001 CD Players
.... ...
1019 Older Electronics

Let's say Table 2 has 12 rows, like this
Table2:
Column1 Column2 ProductCategory
0000001 Dan Old TVs
0000002 Steve Old Computers
.... ...
0000011 Debbie Old Guitars

How do I copy all rows of Table1 to Table2 in as few MySQL statements as
possible ?
In otherwords, without writing 20 separate SQL Insert statements ?

Also, the columns from Table1 go into Table2 as described below:
Table1.CategoryNumber ---> Table2.Column1
"Owners Unknown" ---> Table2.Column2
Table1.CategoryName ---> Table2.ProductCategory

Many thanks for your help and patience regarding this newbie question.
Sincerely,
jc

Jul 19 '05 #1
3 2143
Hi,

You can use this format for insert
INSERT INTO tb2(fldID) SELECT tbl.fldOrder_ID FROM tbl WHERE tbl.fldOrder_ID
100;The where clause is optionalJohan

"JC-Atl" <Em***@WithHeld.net> schreef in bericht
news:xD*****************@bignews4.bellsouth.net... I have 2 tables in a database:

As an example, let's say Table1 has 20 rows, like this:

Table1:
CategoryNumber CategoryName
1000 Radios
1001 CD Players
... ...
1019 Older Electronics

Let's say Table 2 has 12 rows, like this
Table2:
Column1 Column2 ProductCategory
0000001 Dan Old TVs
0000002 Steve Old Computers
... ...
0000011 Debbie Old Guitars

How do I copy all rows of Table1 to Table2 in as few MySQL statements as
possible ?
In otherwords, without writing 20 separate SQL Insert statements ?

Also, the columns from Table1 go into Table2 as described below:
Table1.CategoryNumber ---> Table2.Column1
"Owners Unknown" ---> Table2.Column2
Table1.CategoryName ---> Table2.ProductCategory

Many thanks for your help and patience regarding this newbie question.
Sincerely,
jc

Jul 19 '05 #2
Hi,

You can use this format for insert
INSERT INTO tb2(fldID) SELECT tbl.fldOrder_ID FROM tbl WHERE tbl.fldOrder_ID
100;The where clause is optionalJohan

"JC-Atl" <Em***@WithHeld.net> schreef in bericht
news:xD*****************@bignews4.bellsouth.net... I have 2 tables in a database:

As an example, let's say Table1 has 20 rows, like this:

Table1:
CategoryNumber CategoryName
1000 Radios
1001 CD Players
... ...
1019 Older Electronics

Let's say Table 2 has 12 rows, like this
Table2:
Column1 Column2 ProductCategory
0000001 Dan Old TVs
0000002 Steve Old Computers
... ...
0000011 Debbie Old Guitars

How do I copy all rows of Table1 to Table2 in as few MySQL statements as
possible ?
In otherwords, without writing 20 separate SQL Insert statements ?

Also, the columns from Table1 go into Table2 as described below:
Table1.CategoryNumber ---> Table2.Column1
"Owners Unknown" ---> Table2.Column2
Table1.CategoryName ---> Table2.ProductCategory

Many thanks for your help and patience regarding this newbie question.
Sincerely,
jc

Jul 19 '05 #3
Hi,

You can use this format for insert
INSERT INTO tb2(fldID) SELECT tbl.fldOrder_ID FROM tbl WHERE tbl.fldOrder_ID
100;The where clause is optionalJohan

"JC-Atl" <Em***@WithHeld.net> schreef in bericht
news:xD*****************@bignews4.bellsouth.net... I have 2 tables in a database:

As an example, let's say Table1 has 20 rows, like this:

Table1:
CategoryNumber CategoryName
1000 Radios
1001 CD Players
... ...
1019 Older Electronics

Let's say Table 2 has 12 rows, like this
Table2:
Column1 Column2 ProductCategory
0000001 Dan Old TVs
0000002 Steve Old Computers
... ...
0000011 Debbie Old Guitars

How do I copy all rows of Table1 to Table2 in as few MySQL statements as
possible ?
In otherwords, without writing 20 separate SQL Insert statements ?

Also, the columns from Table1 go into Table2 as described below:
Table1.CategoryNumber ---> Table2.Column1
"Owners Unknown" ---> Table2.Column2
Table1.CategoryName ---> Table2.ProductCategory

Many thanks for your help and patience regarding this newbie question.
Sincerely,
jc

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JC-Atl | last post by:
I have 2 tables in a database: As an example, let's say Table1 has 20 rows, like this: Table1: CategoryNumber CategoryName 1000 Radios 1001 CD...
2
by: ja | last post by:
hi, How copy two table between two database? copy 1 table1 to 2 table2 1 - cursor number, 2 - cursor number, table1 - sourse table table2 - destination table
5
by: Peter CCH | last post by:
Let's say, I have Table1 and Table2, both with the exactly same structure and data in it, except that Table1.Field1 is empty in data but Table2.Field1 have data in it. How could I copy all the...
1
by: Sean Howard | last post by:
Dear All, As is my want I need to do something in Access that seems simple but cannot fathom out. I have main form with two subforms, both datasheets with an almost identical table structure....
4
by: Dejan | last post by:
Hy Sorry for my terreble english. I have mysql table1 on my local comp. It looks something like this. ---------------------------------------------------------------------------- -...
4
by: GTi | last post by:
I have two identical tables with one IDENTITY column and several other columns. I have tested the COPY * INTO table2 FROM table1 WHERE xx but it requers that table2 does not exist. TABLE2 is a...
0
by: Hetal | last post by:
Hi.. I am working on VB.NET 2003 (windows form) application and using ADO.NET to deal with databases. The table structure i am working with is as follows. DB1.Table1 (source)...
10
by: pbd22 | last post by:
Hi. Like the title says - how do i do this? I was given the following example: INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A' The above statement threw the following error:
14
by: Yas | last post by:
Hello, I have 2 tables, Table1 and Table2. I have copied all data from Table1 to Table2. However Table1 is dynamic it has new rows added and some old rows modified everyday or every other...
2
by: suren1503 | last post by:
Hi All Techies, I have created one DTS to copy table1 (which is on Oracle server) to table2 (on SQL Server 2000) I want to copy only new records + modified records from table1 to table2. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.