I have searched many questions and ready many different articles about this but no one seems to help me out or may be I could not able to understand completely. I want to migrate data from one database to another database.
This is my query
$query = mysql_query("
Insert into database2.table2 (id, data)
select (id, name) from database1.table1
");
if($query == false){
die(mysql_error());
}
When I execute this query it shows me this error message which is really annoying Operand should contain 1 column(s)
I searched about it but found nothing which could help me.
Note: This query is initally for my test case. Actual query will be made later.
Try this query (Removing parenthesis from select fields),
INSERT into database2.table2 (id, data) SELECT id, name from database1.table1
Note: Please, don't use mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.