|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
INSERT INTO syntax
I want to copy records from a table in DataBase1 to and identical table in DataBase2.
Code:
USE Database2; INSERT INTO `Accounts` VALUES (SELECT * FROM DataBase1.Accounts); I get the error: "You have an error in your SQL syntax...." and it seems to point to the "SELECT * FROM DataBase1.Accounts" area of the query. My guess is that I am referencing the name "DataBase1" incorrectly. I have seen a reference like "DataBase1.Table1" in SQLyog but I cannot find the section in mySQL manual about how to reference another database. Thanks for your help. John Brown |
|
#2
|
|||
|
|||
|
Just remove the VALUES keyword.
This is a perfectly valid statement as long as the columns match. Code:
INSERT INTO Database2.Accounts SELECT * FROM Database1.Accounts;
__________________
BookMooch.com : Give books away. Get books you want. |
|
#3
|
|||
|
|||
|
That fixed it. Thanks to Inxgeek
That fixed it. Thanks to Inxgeek
Quote:
|
| Viewing: Dev Shed Forums > Databases > MySQL Help > INSERT INTO syntax |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|