>>I have a clients table and a locations table. Each client has and address that is in the locations table. I want to join the clients table to the locations table so I can replace the address in the clients table with the key to that address in the locations table.
>>
>>For the most part, there is only one of each address in the locations table. But because I'm working with bad data, there might be more than one.
>>
>>Is there a join that will take one and only one of each client and match it up to the first address in locations that it finds, and doesn't make a second entry of the same client for the second address in locations?
>>
>>Thanks,
>>
>>-Michelle
>
>If the tables are just in VFP, you can by slight cheating...
>
>
>select a.keyid, a.name, a.fld2, a.fld3,;
> b.address, b.city, b.etc, ;
> count(*);
> from client a, location b;
> where a.keyid = b.keyid
> group by a.keyid
>
>
>This will create a single record based on each key but grab the details for only the first hit in the joined table...
>
>But if you are creating a cursor just to re-update the clients table, you can do a similar process to the delete option...
>
>use location
>set order to keyid
>select 0
>use clients
>set rela to keyid into location
>replace all fld1 with location.fld1, fld2 with location.fld2
>
Well, that won't work as is, but the group by idea may just do what I need...
Thanks,
-Michelle
>This way, you don't need a cursor and then update from the cursor...