0
votes

I want to establish relationship between tables in 2 different databases,

Database1 table1 table2

Database2 table3 table4

relationship with table1 in database1 with table3 in database2

I want to know is this possible in MySQL? if yes I have tried within database but i want to know if this is possible

Be

2

2 Answers

0
votes

Yes it is absolutely possible with the '.' operator. Lets say you have 2 schema db1 and db2. table1 is present in db1 and table2 in db2.

So if you want to join the tables, you can::

Select * from 
db1.table1 inner join db2.table2 on column1=column2
0
votes

Yes, this is possible. Foreign key relations can be made as follows while creating table

CREATE TABLE database1.table1 ( 1 INT, FOREIGN KEY (1) REFERENCES database2.table3(1) ON UPDATE CASCADE );