0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
maxdachs
  • 59
  • 7

2 Answers2

1

Try like this

insert into db1.Tbl1(name,steamid) values (select name, steamid from db2.Tbl2)
Fahim
  • 12,198
  • 5
  • 39
  • 57
0

As of Mysql 5.7 syntax slightly changed

INSERT INTO db1.Tbl1(field1,field2) SELECT field1, field2 FROM db2.Tbl2

Source: Mysql doc

Sapnix
  • 55
  • 1
  • 8