Subject Re: FW: [firebird-support] Is this legal SQL?
Author Helen Borrie
At 10:23 AM 26/01/2004 +0100, you wrote:
>Hi, Helen and Svein Erling!
>
>Table 1:
>Name -> TABLEONE
>Columns -> ARTNR, HISTORY
>
>Table 2:
>Name -> TABLETWO
>Columns -> ARTNR, COLOR
>
>if (exists (select 1 from TABLEONE
> where ARTNR in (select ARTNR from TABLETWO
> where COLOR = 'aValue')
> and HISTORY > 0
> )
> ) then
>begin
>.
>.
>.
>end

Well, Henrik, I think you are trying to make this far more difficult than
it is. This is, after all, only an existential test!!

if (exists (select 1 from TABLETWO T2
JOIN TABLEONE T1
ON T1.ARTNR = T2.ARTNR
where T2.COLOR = 'aValue'
and T1.HISTORY > 0) ) then

/hb