Choice from two bases for one request
-
Good afternoon. Wanted to know if it was possible to select information from different databases for one request?
-
If the request indicates the table in the name of the database
database1.table1
the table is selected fromdatabase1
if it's justtable1
- from the active database.General principle of cross-request for two bases within one MySQL server:
SELECT t1.*, t2.* FROM database1.table1 AS t1 INNER JOIN database2.table2 AS t2 ON t2.field1 = t2.field1
Alias
t1
andt2
Not necessarily. But they reduce the demand, and improve the readability.