Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Select SQL in more than 1 Table
Message
From
09/04/2001 23:46:36
 
 
To
09/04/2001 23:04:09
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00493880
Message ID:
00493890
Views:
16
>I have 2 tables, CLIENT and ADDRESS, both with a unique MNO field which is the client ID number. The ADDRESS table can have any number of records for each client, with a field ADS as the date of address change.
>
>Using Select SQL, I need to extract a list of client names from the CLIENT table and their most recent address record from the ADDRESS table.
>
>I have tried using the MAX(ADS) to extract the most recent record from the ADDRESS table, but it only extracts the actual most recent ADS field itself....the actual address data appears to come from any record in the ADDRESS table.
>
>The code used is:
>
>select max(address.ads), address.ad1, trim(client.sn)+', '+trim(client.fn) as surname , client.mno ;
> from tcdata!address ;
> inner join client ;
> on address.mno=client.mno ;
> where address.can=0 ;
> group by address.mno ;
> order by surname ;
> into cursor boe
>
>Any suggestions would be gratefully received
SELECT MAX(Address.ads) as ads, Address.mno,  ;
       STRTRAN(client.sn - ',,' - client.fn,',',,', ') AS surname, ;
  FROM tcdata!Address ;
 INNER JOIN client ON address.mno = client.mno;
  INTO CURSOR Temp ;
 GROUP BY Address.mno ;
 WHERE Address.can = 0 ;


SELECT Temp.*, ad1;
  FROM Temp ;
 INNER JOIN address ON temp.mno = address.mno AND ;
                       temp.ads = address.ads ;
 ORDER BY surname ;
  INTO CURSOR boe
>
>Regards
>
>Bob
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform