Select & Insert across multiple databases with MySQL

前端 未结 2 2163
生来不讨喜
生来不讨喜 2021-02-07 07:00

I have 2 identical tables in 2 different databases that reside on the same server. What would be the best way to copy data from table to another?

2条回答
  •  清歌不尽
    2021-02-07 07:16

    Just to elaborate slightly on OMG Ponies' answer, you can use any WHERE clause, like so:

    INSERT INTO db1.tablename
    SELECT *
    FROM db2.tablename src
    WHERE src.lastlogin >= '2013-10-31 07:00:00'
    

提交回复
热议问题