From: | "Aaron Bono" <postgresql(at)aranya(dot)com> |
---|---|
To: | "James Cloos" <cloos(at)jhcloos(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: where clause subqueries vs multiple rows results |
Date: | 2006-09-11 04:54:25 |
Message-ID: | bf05e51c0609102154uebc2bc5kebe34b10520d351c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 9/10/06, James Cloos <cloos(at)jhcloos(dot)com> wrote:
>
> 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?
Will this work?
SELECT guid
FROM child
INNER JOIN parent ON (
child.the_fkey = parent.id
AND
)
WHERE name ~ 'some_regex'
ORDER BY
child.the_fkey,
child.my_pkey
;
I am not sure what table name is from but since you say it is n+1 queries I
assume it is from the child table? It would help to know what columns are
on which tables.
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================
From | Date | Subject | |
---|---|---|---|
Next Message | Aaron Bono | 2006-09-11 04:55:02 | Re: where clause subqueries vs multiple rows results |
Previous Message | Robert Edwards | 2006-09-11 04:52:23 | Re: on connect/on disconnect |