MySql Import a record from another Database

How to import a record from another database table in mysql ?

Same Table Structure in Source and Destination Table

INSERT INTO <TABLENAME> SELECT * FROM <DESTINATION DATABASENAME>.<TABLENAME>

Transfer from Limited Fields

INSERT INTO <TABLENAME> (col1, col2) SELECT (col1, col2) FROM <DESTINATION DATABASENAME>.<TABLENAME>

Transfer from Limited Fields with Condition

INSERT INTO <TABLENAME> (col1, col2) SELECT (col1, col2) FROM <DESTINATION DATABASENAME>.<TABLENAME> where condition.field = condition.value

Advertisements