Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL SubQueries!
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00515297
Message ID:
00515326
Views:
15
>I am have a problem with the following sql statement. I get an sql error as follows: Too many subqueries. Is there a limitation in VFP6 on the amount of subqueries in a select statement and what is it? Is there a work around for this problem beyond braking the select up? Thanks for your help!
>
>SELECT names.* ;
> FROM money32!names ;
> WHERE (names.id IN ;
> (SELECT names.id ;
> FROM money32!names ;
> JOIN money32!contrib ON names.id = contrib.id ;
...snip...

You can generally replace WHERE table1.yourfield IN (SELECT table2.yourfield FROM...) with ...FROM table1 INNER JOIN table2 ON table1.yourfield = table2.yourfield... It might also be faster. You already have a lot of JOINs, though.

You can often replace WHERE table1.yourfield NOT IN (SELECT table2.yourfield FROM....) with ...FROM table1 LEFT OUTER JOIN table2 ON table1.yourfield = table2.yourfield WHERE ISNULL(table2.yourfield)... I learned that from Mark McCasland, and I find that it is way faster. But it is less pure SQL and might not work in all cases.

Also, check your parentheses.
Previous
Reply
Map
View

Click here to load this message in the networking platform