aspose file tools
The moose likes JDBC and the fly likes Copy data from one table to another Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply 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: 263
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: 2350

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
ITIL foundation
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 263
Thank you :-)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Copy data from one table to another
 
Similar Threads
Ajax call for window.location.href
Complex HQL query conversion (from SQL)
MySQL update issue
Copy field in the same table
Transposing rows to columns