File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Join between tables in different databases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Join between tables in different databases" Watch "Join between tables in different databases" New topic

Join between tables in different databases

Billy Tobon

Joined: May 11, 2004
Posts: 9
I need to make a join between two tables but they are in different databases (in slqserver2000), I found a ".relation" in c#, but want to use JDBC. There is any solution or workaround?


Compilatum est.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

I've done it in plain old SQL in MySQL using schema1.table1.attribute and schema2.table2.attribute, but in the end I found it easier to dump the table and import it into the other schema. All depends on your requirements. I was just doing some fairly basic (once-off) data conversion.

Actually I think from memory the table is still there...
Phillip Koebbe

Joined: Jun 22, 2005
Posts: 27
In a standard SQL query, it would look something like

As with most of my replies, this is from the hip, but I think it's close. If you are querying with sa or equivalent rights, you don't need the owner, but you still need the dot, so it becomes Database2..t_Table2.

I agree. Here's the link:
subject: Join between tables in different databases
It's not a secret anymore!