In MySQL, I have two different databases -- let's call them A and B.
Is it possible to perform a join between a table that is in database A, to a table that is in database B?
In MySQL, I have two different databases -- let's call them A and B.
Is it possible to perform a join between a table that is in database A, to a table that is in database B?
Yes, assuming the account has appropriate permissions you can use:
SELECT <...>
FROM A.table1 t1 JOIN B.table2 t2 ON t2.column2 = t1.column1;
You just need to prefix the table reference with the name of the database it resides in.
SELECT *
FROM A.tableA JOIN B.tableB
or
SELECT *
FROM A.tableA JOIN B.tableB
ON A.tableA.id = B.tableB.a_id;
SELECT <...>
FROM A.table1 t1 JOIN B.table2 t2 ON t2.column2 = t1.column1;
Just make sure that in the SELECT line you specify which table columns you are using, either by full reference, or by alias. Any of the following will work:
SELECT *
SELECT t1.*,t2.column2
SELECT A.table1.column1, t2.*
etc.