1

I have 2 tables in different databases in different mysql hosts. can i write a single SQL statement to implement the inner join operation?

2

4 Answers 4

1

Depending on your MySQL version, you might be be able to use Federated Storage Engine. Refer to Accessing Distributed Data with the Federated Storage Engine for more information.

Sign up to request clarification or add additional context in comments.

Comments

0

That would mean connecting to another MySQL host from INSIDE the SQL statement. To my knowledge, this is not possible and I would regard it as highly dangerous if it were.

Comments

0

It is not possible to join two tables from different hosts. You can store the result from one of the tables in a hash keyed on the join attribute, and then perform the join operation in your program.

Comments

-4

it is not possible to connect to two databases in same query

2 Comments

to two database it is possible: SELECT db1.tb1.* FROM db1.tb1 LEFT JOIN db2.tb1 ON db1.tb1.field1 = db2.tb1.field1. The question here was more about hosts than databases
Pretty strange that there are a lot of other answers that claim that this is possible

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.