From: | Rajesh Kumar Mallah <mallah(dot)rajesh(at)gmail(dot)com> |
---|---|
To: | Michael B Allen <ioplex(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Must I use DISTINCT? |
Date: | 2009-02-06 03:59:13 |
Message-ID: | a97c77030902051959p6cf1812fsdb936e4dbfd13500@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
have you tried Join using , eg
SELECT e.eid, e.name
FROM entry e join access a ON( e.eid = 120
AND (e.ownid = 66 OR e.aid = a.aid) ) ;
some sample data might also help in understanding the prob
more clrearly.
regds
rajesh kumar mallah.
On Fri, Feb 6, 2009 at 3:27 AM, Michael B Allen <ioplex(at)gmail(dot)com> wrote:
> Please consider the following SQL
>
> SELECT e.eid, e.name
> FROM entry e, access a
> WHERE e.eid = 120
> AND (e.ownid = 66 OR e.aid = a.aid)
>
> The intent is to match one entry with the eid of 120. However I would
> like to impose an additional constraint that either e.ownid must be 66
> or e.aid must match the aid of an entry in the access table (there's
> actually a lot more to the query but I think this should be sufficient
> to illustrate my problem).
>
> The problem is that the e.ownid is 66 and therefore the same entry is
> returned for each access entry.
>
> Of course I can simply SELECT DISTINCT but that seems like an improper
> usage of DISTINCT here.
>
> Is there an alternative way to write this query? I only want to select
> from the access table for the purpose of constraining by aid.
>
> Mike
>
> --
> Michael B Allen
> Java Active Directory Integration
> http://www.ioplex.com/
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Michael B Allen | 2009-02-06 04:54:48 | Re: Must I use DISTINCT? |
Previous Message | Raj Mathur | 2009-02-06 03:34:01 | Re: Array iterator |