Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SELECT's Queries, which includes EXIST filter
Message
From
10/11/1997 18:31:44
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00059303
Message ID:
00059410
Views:
28
It's true that there's not much info in the Help for it. But the explanation is pretty clear, IMHO. Here's a quote from Help for EXISTS:

"When the filter condition includes EXISTS, the filter condition evaluates to true (.T.) unless the subquery evaluates to the empty set."

Here, the "filter condition" is the condition you have in the WHERE clause, ie "EXIST (subquery)". The evaluation of this condition goes like that:
The subquery is run and, obviously, it generates a set of records (you can see it like a temp table or cursor). If this set of records contains at least one record, then the EXIST condition is evaluated to .T. If there are no records in the resulted "set of records" (ie it's an empty set), the condition is evaluated to .F.

An other way of looking at it: if the subquery result contains at least one record, the result exists. If the subquery result contains no records, than the result doesn't exist.

This is also like:
subquery && This is a SELECT ...
IF _tally = 0
EXISTS = .F.
ELSE
EXISTS = .T.
ENDIF
But since you cannot put this code in the WHERE clause of a SELECT-SQL, there is the EXISTS key word that does this for you.

Vlad


>As I know there is SELECT's filter using EXIST, which format is:
>SELECT <...> WHERE EXIST (subquery)
>
>How to use it? I have found very little information about it
>in VFP Help. I have tried it with 2 tables with diferent fields,
>but didn't work. :(
>
>Thanx for Your Help.
Previous
Reply
Map
View

Click here to load this message in the networking platform