Subject Re: [firebird-support] SQL
Author Ann Harrison
> On Aug 28, 2019, at 12:54 AM, Kjell Rilbe kjell.rilbe@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
>
> Den 2019-08-05 kl. 13:20, skrev mohamed hamza medhome@...
> [firebird-support]:
>>
>> Hi All,
>>
>> I am new to sql, I am coming from Xbase system .
>> I want to know if it 's possible to execute query using last query
>> result?
>>
>> EXAMPLE
>> 1 select * from persons where state='CA'
>>
>> 2 select * from persons where age> 18 but we have to use the
>> result of 1
>>
>> I DO NOT WANT TO DO AN AND ( STATE = 'CA' AND AGE > 18 ) ;
>
>
> First: Why not use and AND? That would be the most natural solution.

And will perform best. If both terms are indexed, Firebird will use both indexes.
>
> Second: No, a plain sequence of SQL queries do not support that. But you
> can put them in a stored procedure or an "execute block" statement ...

Would a CTE work?

Good luck,

Ann