Subject Re: Again Sub-Query Problem
Author Svein Erling
--- In firebird-support@yahoogroups.com, Uwe Oeder <uweo@c...> wrote:
> Please tell me this is also a very simple problem.
>
> SELECT <something>
> FROM Whitepage W3 ...
> WHERE ...
> AND
> EXISTS
> (
> SELECT <something>
> FROM Whitepage W2 ...
> )
> AND
> EXISTS
> (
> SELECT <something>
> FROM Whitepage W1
> WHERE ...
> AND
> W1.WpIDSQ = W2.WpIDSQ
> ) ;

Uwe, as you can see from the extract above W2 is declared in a
separate EXISTS, and you cannot reference it outside of that EXISTS.
I.e.

SELECT * FROM A WHERE EXISTS(SELECT * FROM B WHERE B.A_ID = A.ID AND
EXISTS (SELECT * FROM C WHERE C.B_ID = B.ID))

is legal, whereas

SELECT * FROM A WHERE EXISTS(SELECT * FROM B WHERE B.A_ID = A.ID) AND
EXISTS (SELECT * FROM C WHERE C.B_ID = B.ID)

(equivalent to what you wrote) is illegal.

Though I still think you should clean up your SQL if you want to get
useful results.

Set