X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 7E8099FA506 for ; Mon, 11 Sep 2006 01:44:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 25765-01 for ; Mon, 11 Sep 2006 04:44:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ore.jhcloos.com (ore.jhcloos.com [64.240.156.239]) by postgresql.org (Postfix) with ESMTP id 761329FB209 for ; Mon, 11 Sep 2006 01:44:08 -0300 (ADT) Received: from lugabout.jhcloos.org (ppp38.tc-1.buf-ch.ny.localnet.com [69.48.13.38]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "lugabout.jhcloos.org", Issuer "ca.jhcloos.com" (verified OK)) by ore.jhcloos.com (Postfix) with ESMTP id 4E8D51C57E for ; Sun, 10 Sep 2006 23:43:47 -0500 (CDT) Received: by lugabout.jhcloos.org (Postfix, from userid 500) id 80B0F21470B; Mon, 11 Sep 2006 03:28:22 +0000 (GMT) From: James Cloos To: pgsql-sql@postgresql.org Subject: where clause subqueries vs multiple rows results Copyright: Copyright 2006 James Cloos X-Hashcash: 1:23:060911:pgsql-sql@postgresql.org::DEtqlrJCu54hSF4h:0000000000000000000000000000000000001IdzW Date: Sun, 10 Sep 2006 23:27:59 -0400 Message-ID: Lines: 16 User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/58 X-Sequence-Number: 26269 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 OpenPGP: 0xED7DAEA6