Re: Must I use DISTINCT? - Mailing list pgsql-sql

From Raj Mathur
Subject Re: Must I use DISTINCT?
Date
Msg-id 200902061151.56496.raju@linux-delhi.org
Whole thread Raw
In response to Re: Must I use DISTINCT?  (Michael B Allen <ioplex@gmail.com>)
List pgsql-sql
On Friday 06 Feb 2009, Michael B Allen wrote:
> On Thu, Feb 5, 2009 at 10:59 PM, Rajesh Kumar Mallah
>
> <mallah.rajesh@gmail.com> wrote:
> > 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.
>
> Hi Rajesh,
>
> Unfortunately using JOIN does not seem to change the result.
>
> Here is some real data:
> > select eid, name, ownid, aclid from foo_entry;
>
> +-----+---------------------------------------+-------+-------+
>
> | eid | name                                  | ownid | aclid |
>
> +-----+---------------------------------------+-------+-------+
> | 113 | {MD5}ff132413c937ad9fd1ea0d5025891c2d |    66 |     0 |
> +-----+---------------------------------------+-------+-------+
> 15 rows in set (0.01 sec)
>
> > select a, b from foo_link;
>
> +-----+-----+
>
> | a   | b   |
>
> +-----+-----+
> |  71 |  92 |
> +-----+-----+
> 16 rows in set (0.00 sec)
>
> So there are two tables: foo_entry AS e and foo_link AS a1. I want to
> select the the single row from foo_entry with e.eid = 113 but only if
> the e.ownid = 66 OR if e.aclid is indirectly linked with 66 via the
> foo_link table.

Something like this?

select * from foo_entry where eid = 113 and ownid in (select a from 
foo_link where a=66 or b=66);

Regards,

-- Raju
-- 
Raj Mathur                raju@kandalaya.org      http://kandalaya.org/      GPG: 78D4 FC67 367F 40E2 0DD5  0FEF C968
D0EFCC68 D17F
 
PsyTrance & Chill: http://schizoid.in/   ||   It is the mind that moves


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Must I use DISTINCT?
Next
From: "Bart van Houdt"
Date:
Subject: Data length and data precision