pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Broersma Jr <rabroersma@yahoo.com>
To: James Cloos <cloos@jhcloos.com>
To: pgsql-sql@postgresql.org
Subject: Re: where clause subqueries vs multiple rows results
Date: Sun, 10 Sep 2006 22:01:29 -0700 (PDT)
Message-ID: <20060911050129.13298.qmail@web31814.mail.mud.yahoo.com> (raw)
In-Reply-To: <m3y7srm695.fsf@lugabout.jhcloos.org>

> 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.



view thread (5+ messages)  latest in thread

Message-ID: <20060911050129.13298.qmail@web31814.mail.mud.yahoo.com>
Permalink:  ../20060911050129.13298.qmail@web31814.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/20060911050129.13298.qmail@web31814.mail.mud.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rabroersma@yahoo.com, cloos@jhcloos.com
  Subject: Re: where clause subqueries vs multiple rows results
  In-Reply-To: <20060911050129.13298.qmail@web31814.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox