Mirror

How to access data from two different databases (Views: 710)


Problem/Question/Abstract:

Is it possible for access data from two different database such as...

SELECT A.EMP_NAME, B.DEPT_DESC FROM DB1.TB1 A, DB2.TB1 B WHERE
A.EMP_DEPT = B.DEP_KEY

If so how?

Answer:

Yes, this is called a heterogeneous join. An example of this is like:

SELECT DISTINCT c.cust_no, c.state, o.order_no, i.price
FROM ':Local_alias:customer.db' c,
     ':IB_alias:order' o,
     ':SYB_alias:lineitem' i
WHERE o.cust_no = c.cust_no and
      o.order_no = i.order_no

The first part between the :: is the BDE alias for the database you want to include in the heterogeneous
join.

<< Back to main page