Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql question
Message
From
11/06/1998 16:10:38
 
 
To
11/06/1998 15:40:46
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Miscellaneous
Thread ID:
00107324
Message ID:
00107340
Views:
19
>I have a query that I'm pretty sure sql can handle although I can't figure out how.
>I have two tables: an invoice table and a customer table.
>I'd like to select those distict accountnum1, accountnum2 from the invoice table for a given date range and then join the result of that with the customer file (acctnum1, acctnum2) so I can have the full address. I like to be able to have this all in one sql statement. Any help would be appreciated.

Can you clear if the invoice has two different customer account numbers? Doesn't sound logical. If I can guess correctly, the join will be on the customer account number, and say you have:
Invoice    Customer
-------    --------
Invo_ID    Cust_ID
Cust_ID    Cust_Addr
then the statement will look like:
Select Distinct a.Cust_ID, b.Cust_Addr ;
  From Invoice a, Customer b ;
  Where a.CustID=b.CustID
If you have another customer ID whose address needs to be obtained then you can join another Select statement with the UNION keyword, in the same format of the above. Now guessing further if you have two invoice numbers and want to get the address of the customer, you don't need to SELECT DISTINCT, you just do the straight
Select a.Cust_ID, b.Cust_Addr ;
  From Invoice a, Customer b ;
  Where a.Cust_ID=b.CustID
But then again I may be just guessing too much.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform