Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using an sql statement as a condition in another action
Message
From
31/03/2000 16:10:17
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvania, United States
 
 
To
31/03/2000 15:01:12
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00353571
Message ID:
00353630
Views:
16
>I have a table with three fields, including one logical. I want to change the logical to .T. for every record that contains a unique entry. I've tried REPLACE MyTABLE.FIELD3 WITH .T. FOR (SELECT DISTINCT FIELD2 FROM MyTABLE) but I get a "Function name is missing )." What am I doing wrong?

The FOR clause must be a boolean value, the SELECT returns a record set. I don't know if there is a way to make that work. BTW, distinct doesn't return unique records, it just makes sure the output only has one of each in a group

try this:
Sele field2 as pk, cnt(field2) as cntpk from mytable into table c:\grpcnts
index on pk tag pk
sele mytable
set relation to field2 into grpcnts
Update mytable set field3=.T. where grpcnts.cntpk = 1

I tried this on a small table, and it works. If you have really large tables, it might be slower. I'd guess there's a better way, but A way is better than No way.
Previous
Reply
Map
View

Click here to load this message in the networking platform