This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Copy data from one table to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Copy data from one table to another" Watch "Copy data from one table to another" New topic
Author

Copy data from one table to another

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Hello, I want to copy some data from one table (orderpaymentno) to another table (order) in mySQL. The two tables are not identical.

I also have to predefine some data in the new table. This is the SQL query I have tried out but it doesn�t work.

Can anyone help me correcting the SQL query ?
[ February 19, 2007: Message edited by: Jeppe Fjord ]
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2543
    
  10

In the INSERT INTO clause, you can only put column names.
If the values 2, 2, 'Afdeling (I understand that!)' and 2 need to be fixed values, then you must put their column name in the INSERT INTO clause, and their value in the SELECT clause:



Regards, Jan


OCUP UML fundamental and ITIL foundation
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Thank you :-)
 
Have you checked out Aspose?
 
subject: Copy data from one table to another
 
It's not a secret anymore!