Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tip of the Day -- SQL Subqueries
Message
De
30/09/1999 13:07:41
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00271146
Message ID:
00271183
Vues:
22
>You probably already knew that the SQL "SELECT" statement will accept a subquery in the WHERE clause, as in
>
>select * from myTable1 ;
>   where myTable1.cField1 in ( select cField1 from myTable2)
>
>
>It turns out that you can do this in SQL "DELETE" and "UPDATE" commands too. This is implied in the VFP Help, but not explicitly stated. For example, you can:
>
>delete from myTable1 ;
>   where myTable1.cField1 in ( select cField1 from myTable2)
>
>and you can
>
>update myTable1 set cField3 = "X" ;
>   where myTable1.cField1 in ( select cField1 from myTable2)
>
>
>File it under "U", for "Useful, Someday It Might Be".

Thanks, Rick. These commands are very useful. In my experience the DELETE SQL with subquery is fast and straightfoward. UPDATE SQL ,on the other hand, is usually easier to code, understand and execute using Xbase REPLACE with appropriate relations set.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform