>>UPDATE MyTable SET Field3 = .T. WHERE NOT Field2 IN (SELECT Field2 FROM MyTable WHERE Field3)
>
>This works in theory only:
>
>suppose that every record field3 = .F.
>..the subquery will yield no results, and the update will set every field3=.T.
>
>Considering that MyTable is likely to start with field3 being unassigned and the records being added with possible dupes on field2, it is likely this statement will be toggling the field3 values.
>
>The update sql is a great way to do this job, but like an SQL-Select, it takes a bit of tweaking before you get the correct results.
Michael,
the subquery will be reexecuted for each record in a table and only in case the value of Field2 absent in the subquery result, the Field3 will be changed.
Here is the small update (but, anyway, previous solution also works):
UPDATE MyTable SET Field3 = .T. WHERE Field2 NOT IN (SELECT Field2 FROM MyTable WHERE Field3)
Alex
Alex