Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2006
    Posts
    5

    Unanswered: 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?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2006
    Posts
    5
    This is Microsoft SQL running Enterprise Manager ver 8.0. I might be in the wrong forum

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •