Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding sub-query
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01514783
Message ID:
01514794
Views:
55
>Hi,
>
>In order to make sure that my SQL Select will work (different from the one I use here as an example) I need to understand how sub-queries work.
>
>Here is a sample SQL Select:
>
>select fk_fld, flda, fldb from Table1 where fk_fld IN (select pk_fld from Table2 where <somecondition> 
>   group by pk_fld)
>
>
>My question is, does VFP (or SQL server) when executing the above SQL Select executes the sub-query first (one time) and then executes main query checking every record of Table1 to see if value FK_FLD is in sub-query?
>
>TIA.

Yes, this is how it's executed. I prefer using EXISTS subquery, though, instead of IN/NOT IN. It may perform faster than IN subquery.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform