X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B69D3D95A7 for ; Thu, 22 Sep 2005 17:48:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05411-09 for ; Thu, 22 Sep 2005 20:48:41 +0000 (GMT) Received: from mail.aveo.aveopharma.com (67.109.105.227.ptr.us.xo.net [67.109.105.227]) by svr1.postgresql.org (Postfix) with SMTP id D5CA8DABC3 for ; Thu, 22 Sep 2005 16:07:59 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Help with a view Date: Thu, 22 Sep 2005 15:10:42 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Help with a view Thread-Index: AcW/of/j3X0DJNE6SxyCjbQi6R9TYwABjg6A From: "Dmitri Bichko" To: "Leif B. Kristensen" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.068 required=5 tests=[AWL=0.018, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/217 X-Sequence-Number: 22764 I don't understand how this is different: SELECT person FROM principals WHERE event IN (SELECT event FROM principals WHERE person =3D $p AND tag_type =3D " .MARR. ") AND person !=3D $p ORDER BY sort_date Or without subselects: SELECT p1.person FROM principals p1 JOIN principals p2 USING(event) WHERE p2 person =3D $p AND p2.tag_type =3D " .MARR. " AND p1.person !=3D $p ORDER BY sort_date Am I being confused? Dmitri > -----Original Message----- > From: pgsql-sql-owner@postgresql.org=20 > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Leif B.=20 > Kristensen > Sent: Thursday, September 22, 2005 2:12 PM > To: pgsql-sql@postgresql.org > Subject: Re: [SQL] Help with a view >=20 >=20 > On Thursday 22 September 2005 20:03, Dmitri Bichko wrote: >=20 > > SELECT * FROM principals WHERE event =3D 15821 AND person !=3D 2? >=20 > Sure, that's a concise answer to what I actually wrote, but it wasn't=20= > exactly what I intended :) >=20 > Basically, what I've got is the first person and the=20 > tag_type. I can do=20 > it with a function from PHP: >=20 > function get_spouses($p) { > $handle =3D pg_query("select person from principals > where event in (select event from principals > where person =3D $p and tag_type =3D " .MARR. ")= > order by sort_date"); > $i=3D0; > $spouses =3D array(); > while ($row =3D pg_fetch_row($handle) { > if $row[0] !=3D $p > $spouses[$i++] =3D $row[0]; > } > return $spouses; > } >=20 > But this is *ugly* ... > --=20 > Leif Biberg Kristensen > http://solumslekt.org/ >=20 > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings >=20 The information transmitted is intended only for the person or entity to = which it is addressed and may contain confidential and/or privileged mate= rial. Any review, retransmission, dissemination or other use of, or takin= g of any action in reliance upon, this information by persons or entities= other than the intended recipient is prohibited. If you received this in= error, please contact the sender and delete the material from any comput= er