Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9B0AD47636C for ; Tue, 8 Oct 2002 12:44:47 -0400 (EDT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by postgresql.org (Postfix) with ESMTP id EAA1F47631B for ; Tue, 8 Oct 2002 12:44:46 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 17yxTX-000NqQ-0U; Tue, 08 Oct 2002 17:44:51 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 9D08D1791A; Tue, 8 Oct 2002 17:44:30 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 06107178C0; Tue, 8 Oct 2002 17:44:29 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Charles Hauser Subject: Re: Problems Formulating a SELECT Date: Tue, 8 Oct 2002 17:44:15 +0100 User-Agent: KMail/1.4.3 Cc: PSQL_list References: <1034018651.2282.38.camel@pandorina.biology.duke.edu> <200210080938.37634.dev@archonet.com> <1034089459.4283.21.camel@pandorina.biology.duke.edu> In-Reply-To: <1034089459.4283.21.camel@pandorina.biology.duke.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200210081744.15596.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/112 X-Sequence-Number: 9829 On Tuesday 08 Oct 2002 4:04 pm, Charles Hauser wrote: > Richard, > > Thanks, a followup. > > I believe this will not work (novice, so take w/ grain of salt). > > I tried the following: > > chlamy_est=3D> CREATE VIEW contig_x_vw AS SELECT contig_id FROM clone_con= tig, > clone WHERE chlamy_est-> clone_contig.clone_id =3D clone.clone_id AND > read=3D'x'; > CREATE > chlamy_est=3D> CREATE VIEW contig_y_vw AS SELECT contig_id FROM clone_con= tig, > clone WHERE chlamy_est-> clone_contig.clone_id =3D clone.clone_id AND > read=3D'y'; > CREATE > chlamy_est=3D> SELECT contig_id FROM contig_x_vw, contig_y_vw WHERE > contig_x_vw.clone_id =3D chlamy_est-> contig_y_vw.clone.id; > ERROR: Column reference "contig_id" is ambiguous My bad, I didn't test it - for the last one you'll want SELECT contig_x_vw.contig_id FROM contig_x_vw ... It doesn't matter which id you use (since you want the value in each) but y= ou=20 will need to tell PG which one you want. > If I understand the logic, you SELECT: > all contig_ids where where clone.read =3D 'x' (VIEW contig_x_vw) > all contig_ids where where clone.read =3D 'y' (VIEW contig_y_vw) > find isect of these two wehere their clone_ids are same > > > However, their clone_ids will never be the same as in the example. It's checking the "contig_id"s are the same (from clone_contig) - if that= =20 isn't what's wanted you can check the columns below match. Otherwise, you'r= e=20 quite right, that's what it's doing. > cloneA.project=3DcloneB.project > cloneA.plate=3DcloneB.plate > cloneA.row=3DcloneB.row > cloneA.col=3DcloneB.col > > > TABLE clone 'A' 'B' > > clone_id 12018 12019 > project 894 894 > plate 27 27 > row G G > col 9 9 > read x y Does that get you any further? If not, I'm back at my desk tomorrow 9am GMT - Richard Huxton