maxdachs maxdachs - 6 months ago 35
MySQL Question

How to select from one database and insert it into another?

I have 2 MySQL databases with 1 table in each one.

Table1 (name,steamid,time)
Table2 (name,steamid)

Now I want to select all data from Table1, where the Time (in sec.) is for example more than 500. And then I want to insert the name and the steamid into the Table 2, if the steamid does not exist in Table2.

How is this possible? The tables are in 2 databases and not in the same one.


Try like this

insert into db1.Tbl1(name,steamid) values (select name, steamid from db2.Tbl2)