Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - SELECT: 'Too many subqueries'
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00319286
Message ID:
00321460
Views:
24
Hi Bret,

I've just found this message, sorry for delay with answer...

>> The problem with JOINs, that we can not use JOIN for NOT expression. (I got this from Help).
>
>That's right. Your query builder would need to build something different if your users chose the "exclude these" option.

Yes, I can treat these two cases differently, but for simplicity I'd better use subqueries in both cases. I have only 3 long lists, so I plan to use instead of IN (codes) 'IN (Select code from '+this.CursorName+')'. I would change only IN expression, and leave INLIST() if user selects less than 24 items. It's not hard to implement this way. Unfortunately, as I already mentioned, I worked as a team member, and other members have their own opinions here...

Regarding to flaky behavior of multilist my collegue adviced to create a multiselected grid. It seems to me, that it's a very tough work...


>> And we can not use more than 2 subqueries in one Query, if it's correct statement...
>
>You can join subqueries in a series of ANDs. I just made one with three:
>
>SELECT myfields FROM myparent WHERE mykey IN (SELECT parentkey FROM lookup1 WHERE somefield = 3) AND mykey IN (SELECT parentkey FROM lookup2 WHERE somefield < 42) AND mykey IN (SELECT parentkey FROM lookup3 WHERE someotherfield = "something")
>
>That doesn't mean it would be the best way.

Actually, in real life could be only one long list of items, so only one subquery, and I may not worry about it. In theory there could be three as a maximum.


>I still think that if you want to go beyond tweaking your code with SYS(3055), my previous suggestion of filtering the data with one lookup at a time using interim cursors will likely be the best. Each interim cursor will be built with only one INNER JOIN or subquery, and you can have as many of them as you are likely to want, since each one will be smaller than the last. Let me know if that suggestion needed a better explanation.

It seems very clear to me. BTW, I already implemented cursor idea, so I just have to reconstruct my where expression right...

>> Life is too complicated... :(
>
>Hopefully they are paying you accordingly. If not, someone else will, eventually. :) :) :)

Yes, eventually :)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform