On Mon, Feb 8, 2016 at 12:05 PM, Johannes <jotpe@posteo.de> wrote:
Hi,
is there a best practice to share data between two select statements?
Imaging following situation: I want to receive two result sets from two tables, referring to a specific id from table t0 AND I try not to query for that specific id a second time.
begin; select id, col1, col2, ... from t0 where id = (select max(id) from t0 where col1 = value1 and col2 = value2 and ...); select col1 from t1 where t0_id = (select max(id) from t0 where col1 = value1 and col2 = value2 and ...); commit;
Please confirm:
You want the result of "SELECT max(id) FROM t0" to be used in the second query without having to recompute it?
What client are you using to execute these statements?