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 975E9DAA86 for ; Thu, 22 Sep 2005 15:12:21 -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 22333-01 for ; Thu, 22 Sep 2005 18:12:17 +0000 (GMT) Received: from mail48-s.fg.online.no (mail48-s.fg.online.no [148.122.161.48]) by svr1.postgresql.org (Postfix) with ESMTP id E9D4EDA864 for ; Thu, 22 Sep 2005 15:12:17 -0300 (ADT) Received: from [192.168.0.57] (062016183238.customer.alfanett.no [62.16.183.238]) by mail48.fg.online.no (8.12.11/8.12.11) with ESMTP id j8MICFSV000430 for ; Thu, 22 Sep 2005 20:12:16 +0200 (CEST) From: "Leif B. Kristensen" To: pgsql-sql@postgresql.org Subject: Re: Help with a view Date: Thu, 22 Sep 2005 20:12:15 +0200 User-Agent: KMail/1.8.1 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200509222012.15463.leif@solumslekt.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.073 required=5 tests=[AWL=0.073] X-Spam-Level: X-Archive-Number: 200509/211 X-Sequence-Number: 22758 On Thursday 22 September 2005 20:03, Dmitri Bichko wrote: > SELECT * FROM principals WHERE event = 15821 AND person != 2? Sure, that's a concise answer to what I actually wrote, but it wasn't exactly what I intended :) Basically, what I've got is the first person and the tag_type. I can do it with a function from PHP: function get_spouses($p) { $handle = pg_query("select person from principals where event in (select event from principals where person = $p and tag_type = " .MARR. ") order by sort_date"); $i=0; $spouses = array(); while ($row = pg_fetch_row($handle) { if $row[0] != $p $spouses[$i++] = $row[0]; } return $spouses; } But this is *ugly* ... -- Leif Biberg Kristensen http://solumslekt.org/