Received: from hotmail.com (f194.law14.hotmail.com [64.4.21.194]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f61Gdra38735 for ; Sun, 1 Jul 2001 12:39:53 -0400 (EDT) (envelope-from oomoomi@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 1 Jul 2001 09:39:51 -0700 Received: from 213.29.16.6 by lw14fd.law14.hotmail.msn.com with HTTP; Sun, 01 Jul 2001 16:39:51 GMT X-Originating-IP: [213.29.16.6] From: "omid omoomi" To: gary.stainburn@ringways.co.uk, pgsql-sql@postgresql.org Subject: Re: My First Function Date: Sun, 01 Jul 2001 16:39:51 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 01 Jul 2001 16:39:51.0841 (UTC) FILETIME=[734EF910:01C1024C] X-Archive-Number: 200107/4 X-Sequence-Number: 3785 > >I want to be able to pass a member ID and a function ID and return the >highest permission for the two. The cut-down schema is: > Hello , Perhaps this SQL works for you: select PPID,Max(PPERM) from permtable where PFID = 'FUNCTION_ID' and PPID in ( select HPID from holdertable where HMID='MEMBER_ID' ) group by PPID; You will face some problems returning more than one value from this SQL if using it in a function. Though,I believe if you are going to use a PHP script it can easilly be handled with it. Hope that helps Omid Omoomi _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.