Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 14th, 2003, 03:54 PM
Authorized User
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to nlicata
Default 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)...

  #2 (permalink)  
Old August 15th, 2003, 03:34 AM
Friend of Wrox
Join Date: Jun 2003
Location: Cardiff, , United Kingdom.
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts

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

So you could use the following SQL:

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.

Owain Williams

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with query for multiple totals cstooch Classic ASP Professional 0 May 13th, 2006 12:09 PM
Need help : how to query multiple categories will2kready SQL Language 0 January 10th, 2006 09:37 PM
Multiple field query PLUS Durwood Edwards Access 5 July 26th, 2005 09:08 AM
Multiple table Query-HELP Kathryn SQL Language 1 March 22nd, 2005 10:57 AM
Multiple Joins in Multiple Table Search query pookster Access 4 September 23rd, 2004 03:04 PM

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