> I've a query which I'd have liked to word akin to:
> 
>   SELECT guid FROM child WHERE the_fkey =
>          ( SELECT id FROM parent WHERE name ~ 'some_regex' )
>          ORDER BY the_fkey, my_pkey;
> 
> I got around it by doing the SELECT id first, and then doing a SELECT
> guid for each row returned, appending the results together.
> 
> Can that be done in a single query, insead of 1+n queries?

select guid 
from child C join parent P
on (C.the_fkey = P.di)
Where P.name ~ 'some_regex'
order by C.the_fkey, P.my_pkey;

Perhaps this might work.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to