Many to Many relation with two different database
How to create many to many relation with different database
A relationship allows to add a jointure in the query in order to retrieve related data from the same database.
If you need to retrieve data from several databases, do it step by step : first from the first database, and then from the second one.
@ankan600 You can’t. Pretty much every relational database won’t let you do foreign keys/joins across databases.
Depends on what you mean by different databases. Is it two completely different servers, or are we talking same server two different schemas?
With two servers it will not work, but it might with different schemas, just make sure to add the schema name.
SELECT *
FROM schema1.authors,
schema2.books
WHERE schema.authors.id = schema2.books.author_id
I have never tried creating schema spanning constraints though, but in theory it should work.
Please or to participate in this conversation.