Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select with Subquery confusion
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00053103
Message ID:
00053628
Views:
27
>Ohhhhhhh.... I see now, Thank You Vlad! So the answer to my original question "What did I do wrong" is that I did NOT setup the subquery to depend on the main query.

I believe the real answer/solution was given by Ed (hope I'm right), because you don't need a subquery in this case. In my opinion, you misused the EXISTS keyword.

>Even though I am only using a single table, I STILL have to setup a JOIN condition to tie the main query to the subquery?

Generally speaking, no.

>I went back through the documentation too, and I think I understand this now. >It seems when a SELECT statement contains a Subquery, the subquery is actually run for each record in the main query?

I'm not sure the subquery is run for each record. I think/hope :) that VFP is smart enough to not run the subquery again if it doesn't depend on each record.

But if it depends on each record in the main query, yes, it is run for each record.

>Therefore creating the need to setup a Join condition to tie the subquery to each record in the main query?

This is not a rule. It depends on what you want to do.

Vlad
Previous
Reply
Map
View

Click here to load this message in the networking platform