Results 1 to 3 of 3

Thread: customer table

  1. #1
    Join Date
    Feb 2005
    Posts
    76

    Unanswered: customer table

    I have a customer table with the column "invoice_customer" (this is the customer_acccount of account where the bill is invoiced..)

    so to get the invoice_customer address for the customer account - 13301

    SELECT B1.address as InvoiceAddress
    from CUSTOMER AS B1 , CUSTOMER AS E1
    WHERE B1.customer_account = E1.invoice_customer and E1.customer_account = '13310'

    i want to add the above InvoiceAddress to the query below:

    select customer_account, order_no, date_req, del_address (InvoiceAddress)
    from CUSTOMERS
    INNER JOIN Orders on CUSTOMERS.customer_account = Orders.account
    where status 'D'

    How would I put the 2 togtheer...

    Thanks in advance!!!
    Last edited by STUCK1234; 02-13-07 at 10:11.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    please always identify exactly which table each of your columns comes from

    if you don't, you're making us guess, and do extra work trying to figure out what you're doing
    Code:
    select E1.customer_account
         , O.order_no
         , O.date_req
         , B1.address as InvoiceAddress
      from CUSTOMERS as B1
    inner
      join CUSTOMERS as E1  
        on E1.invoice_customer = B1.customer_account
       and E1.customer_account = '13310'
    INNER 
      JOIN Orders as O
        on O.account = B1.customer_account 
     where B1.status = 'D'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2005
    Posts
    76
    Im sorry I will try and be more careful next time..

    Thanks for your help

Posting Permissions

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