Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using an sql statement as a condition in another action
Message
De
31/03/2000 18:56:41
 
 
À
31/03/2000 18:20:58
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvanie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00353571
Message ID:
00353721
Vues:
14
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform