So I have this simple query in PostgreSQL 10.
with bunch_of_things as (
select vans_id from shoes where adidas_id = 1
)
select * from vans where vans.id in (bunch_of_things) ;
I am getting an error column "bunch_of_things" does not exist
I know I could put the first select inside the parentheses of the second query, to define the IN part
But since I will use the results of the first query multiple times in the same transaction, I dont want to do the same query multiple times.
So how can I make the IN work along with a CTE?
(And if this is not possible, how can I get the results of a query once and use them multiple times in a transaction?)
Thanks