p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Language (http://p2p.wrox.com/forumdisplay.php?f=100)
-   -   Multiple Database query (http://p2p.wrox.com/showthread.php?t=2814)

nlicata August 14th, 2003 03:54 PM

Multiple Database query
 
Dear Jason, :)

Is there any way to query 2 databases simultaneously in a single query? I do not have the ability to use views or stored procs, if they even would have helped.

The telcom company I am querying has our main customer db and the a supplimental db which holds a single table. The table is a relation between area codes, citys, and local carriers.

I am trying to get a count of phone numbers from my customer database and compare that list to the table mentioned above to get a count of how many of our customers are on each local carrier. Without the seperate DBs it would be a breeze but I cannot find a reference for multi-DB query in any of my resources.

Thanks in advance to whomever (prob Jason)...

Nick

owain August 15th, 2003 03:34 AM

Depending on the RDBMS you are using you may be able to qualify the table names with the database names.

Code:

DatabaseName.TableName.FieldName
So you could use the following SQL:

Code:

SELECT COUNT(Cust.phone_no), Sup.local_carrier
FROM customer.customers AS Cust, supplimental.table AS Sup
WHERE Cust.CarrierID = Sup.CarrierID
GROUP BY Sup.local_carrier

You may want to check my syntax, however the theory is there.

Regards
Owain Williams


All times are GMT -4. The time now is 07:22 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.