where clause subqueries vs multiple rows results

From: James Cloos <cloos(at)jhcloos(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: where clause subqueries vs multiple rows results
Date: 2006-09-11 03:27:59
Message-ID: m3y7srm695.fsf@lugabout.jhcloos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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?

Thanks,

-JimC
--
James Cloos <cloos(at)jhcloos(dot)com> OpenPGP: 0xED7DAEA6

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Aaron Bono 2006-09-11 04:28:43 Re: on connect/on disconnect
Previous Message Robert Edwards 2006-09-11 00:57:24 on connect/on disconnect