Received: from stan.ringways.co.uk ([213.38.87.130]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6K9eca96664 for ; Fri, 20 Jul 2001 05:40:38 -0400 (EDT) (envelope-from gary.stainburn@ringways.co.uk) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with smtp (Exim 3.13 #1) id 15NWYv-0006ND-00 for pgsql-sql@postgresql.org; Fri, 20 Jul 2001 10:27:09 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: "pgsql-sql" Subject: multiple lookup per row Date: Fri, 20 Jul 2001 10:39:16 +0100 X-Mailer: KMail [version 1.2] MIME-Version: 1.0 Message-Id: <01072010391603.16118@gary.ringways.co.uk> Content-Transfer-Encoding: 8bit X-Archive-Number: 200107/266 X-Sequence-Number: 4063 Hi all, I've got a table 'phones' which has an indexed key 'pid' of type int4, and a phone number of type varchar(12). I've then got a table 'members' which as an index key 'mid' of type int4. Now, obviously, if each member only had one phone number, I could simply pull it in using a join. My problem is that each member has (potentially) a voice line 'mphone', a fax line 'mfax', and a mobile (that's a cellphone to you lot over the pond) 'mmobile'. How would I embelish a 'select * from members........' so that it included the three phone numbers if they exist? The only solution I can think of is to write a plpgsql function to do the lookup and call that three times as part of the select, something like select *, getphone(mphone) as phone, getphone(mfax) as fax..... but a purely SQL solution would be nicer. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000