How to save the result of a select statement so that I can reuse the results with a sentence infor other queries? Here are a few pseudo codes:
declare
ids <type?>;
begin
ids := select id from table_with_ids;
select * from table1 where id in (ids);
select * from table2 where id in (ids);
end;
... or will the optimizer do this for me if I just put a subquery in both select statements?
EDIT: Here is more information about the structure of my tables.
Basically, table1 is a standard table with an identifier that is a primary key. Although table2 has a primary key with three columns, the identifier is one of these columns. In my case, the identifier in table2 will be displayed in three lines.
source
share