Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use select... where EXISTS ... ?
Message
From
27/05/2003 11:26:53
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00793069
Message ID:
00793129
Views:
32
>>Sergey,
>>
>>>You can also rewrite it as follow (it may be faster)
>>>
SELECT taitem.ident;
>>>       FROM taitem;
>>>       WHERE code IN (SELECT arcode.code FROM arcode ;
>>>	                  WHERE arcode.activity = "EA")
>>>
>>
>>I'm almost positive that an EXISTS select is going to be faster than an IN select. AFAIK exists allows the inner select to be run only once. IN forces it to be run for every row in the outer select.
>
>Hi David,
>
>It's actualy opposite. IN subquery runs once and than result is used by the main query. The EXISTS uses correlated subquery so it has to run for every record in the main query.

Even more interesting to me is:
How can I know which will run once and which will really be a correlated subquery?

Also, wouldn't both cases be run every time **IF** there was a field from the record itself included in the subquery's WHERE clause? (say like WHERE ARCODE.Activity = TAITEM.ActionCode)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform