1

I have a project where I have two MySQL databases. They are completly separated. They are on two different servers. There is no way to use just one.

Is it possible to connect them both together that I could use e.g. LEFTJOIN? Or do I have to split it in two separate queries and compare them by myself?

Mr.Tr33
  • 838
  • 2
  • 18
  • 42

1 Answers1

3

As long as a db user used to connect to first database has the access to the second, you can do cross-db joins, you just need to specify them:

SELECT db1.table.field, db2.othertable.otherfield
FROM db1.table
JOIN db2.othertable ...
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
Marc B
  • 356,200
  • 43
  • 426
  • 500