Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using an sql statement as a condition in another action
Message
 
To
31/03/2000 16:46:48
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvania, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00353571
Message ID:
00353778
Views:
16
>>UPDATE myTable SET mytable.field3 = .t. WHERE field2 in (SELECT field2 from myTable GROUP BY Fileld2)
>
>I tried something like that in VFP6SP3 and it kep telling me that the subquery was invalid. I tried the subquery as a main query, and it executed properly.
>
>Given that the end result is to have field3=.T. for those records whose field2 value does not occur anywhere else (field2 is unique) the subquery needs to be more like:
>
>Update mytable set field3=.T. where field2 in (Select field2, CNT(FIELD2) as F2CNT from myTable group by field2 HAVING F2CNT=1)
>
>This syntax would be ideal, but i couldn't make it work- so i offered an xBase solution which is probably an order of magnitude more clumsy.

Yeah, it all needs some playing around usually.
There also may be the different solutions with REPLACE, for example
to build the temporary UNIQUIE index, then REPLACE ALL field3 with .t.

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform