Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL REPLACE help
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00530393
Message ID:
00531143
Views:
15
The REPLACE is working well for me but now a new twist. I now need to produce a report of the changes. A column for old lastname and new lastname. Any ideas on how I can accomplish that?

Brenda

****************************
>SET ORDER TO ssn IN table2
>SELECT table1
>SET RELATION TO ssn INTO table2
>REPLACE table1.lastaname WITH table2.lastaname ;
> FOR FOUND("table2") AND table1.lastaname <> table2.lastaname
****************************
>>UPDATE table1 set table1.lastname = table2.lastname where table1.ssn = table2.ssn
>>
>>if both table1 and table at the first record then nothing is replaced in my little example. the record pointer of table2 is not moving. i am wanting for each record in table1 that all records in table2 are searched until an SSN match is found and then lastname is replaced. Just thought I could do it in an SQL statement.
>>
>>Brenda
*******************
>
>>
>>Let's see your UPDATE statement.
>>
>>heers
>>imN
>
>***************
>>
>>The UPDATE is not working as I would like. For a different example. Table1 has SSN and LastName. Table2 has SSN and LastName and is used to update LastName in several tables. Not all the records in Table1 will be in Table2 and not all the records in Table2 will be in Table1. If Table1.SSN = Table2.SSN and Table1.LastName = Table2.LastName I want to replace Table1.LastName with Table2.LastName.
>>
>>Table1
>>------
>>1234567Smith
>>2222222Jones
>>
>>Table2
>>-------
>>1111111Anderson
>>1234567Wilson
>>
>>I want to replace Smith in Table1 with Wilson. But my UPDATE WHERE compares only the values in the current record. It does not move through the table to compare for each record.
>>
>>Will an UPDATE work for me or should I just do it programmatically.
>>
>>Brenda
>********************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform