Den 2019-08-05 kl. 13:20, skrev mohamed hamza medh...@hotmail.com 
[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.

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, and 
save results in variables for later use.

For example:

set term #;
execute block as
declare person_id int;
begin
   for select id from persons where state = 'CA' into :person_id
   do select * from persons where age > 18 and id = :person_id;
end#
set term ;#

But you still end up with an "and" in your second SQL.

Maybe it's best if you explain what you're actually trying to achieve, 
and what the actual problem is, because using AND is not really a 
problem at all.

Regards,
Kjell Rilbe



[Non-text portions of this message have been removed]

  • [firebir... mohamed hamza medh...@hotmail.com [firebird-support]
    • Re:... Kjell Rilbe kjell.ri...@marknadsinformation.se [firebird-support]
      • ... Ann Harrison aharri...@ibphoenix.com [firebird-support]
    • Re:... Richard Damon rich...@damon-family.org [firebird-support]
      • ... mohamed hamza medh...@hotmail.com [firebird-support]

Reply via email to