If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > multiple db, table, column query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-06, 11:03
uraslomo uraslomo is offline
Registered User
 
Join Date: Oct 2006
Posts: 5
multiple db, table, column query

Ok, if you got this far you must have an idea what im looking for. I have two DB's. I need to query four columns in two tables in two DB's at the same time to produce a list of info in order of address(last part I can do )example: DB1 has table "customers" with columns, address,cust number, phone. second DB2 has table "site", with columns cust number, amount owed, unique code, last bill date. I need to reference the customer number in both to match to get a result containing, "customer number, address, unique code, and amount owed.
sound easy to anyone?
Reply With Quote
  #2 (permalink)  
Old 10-25-06, 11:24
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
which database is this?
Code:
select t1.custnumber
     , t1.address
     , t2.uniquecode
     , t2.amountowed
  from DB1.customers as t1
inner
  join DB2.site as t2
    on t2.custnumber = t1.custnumber
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-25-06, 11:39
uraslomo uraslomo is offline
Registered User
 
Join Date: Oct 2006
Posts: 5
This is Microsoft SQL running Enterprise Manager ver 8.0. I might be in the wrong forum
Reply With Quote
  #4 (permalink)  
Old 10-25-06, 12:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
most database systems support (some subset of) standard SQL, so no, you aren't necessarily in the wrong forum, however, there are often significant differences in the variants of SQL from one database system to another

in this case, SQL Server requires the owner name between the database name and the table name, or, at least, requires the missing period

so it would be DB1.dbo.customer or DB1..customer
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On