Question

I'm trying to copy the contents of a column in one mysql database to an identical table in another mysql database.

I'm using:

UPDATE db1.table
SET    db1.table.name = db2.table.name, 
       db1.table.address = db2.table.address
WHERE  db1.table.id = db2.table.id;

I'm getting the error 1054: Unknown column 'db2.table.id' in 'where clause'.

Both tables have an id column, so I'm not sure why it won't work. I'm logged in as admin, and have full rights to both databases.

Was it helpful?

Solution

UPDATE db1.table
JOIN   db2.table
ON     db1.table.id = db2.table.id
SET    db1.table.name = db2.table.name, 
       db1.table.address = db2.table.address
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top