Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tip of the Day -- SQL Subqueries
Message
From
30/09/1999 13:07:41
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00271146
Message ID:
00271183
Views:
30
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform