Re: Must I use DISTINCT?

From: Raj Mathur <raju(at)linux-delhi(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Must I use DISTINCT?
Date: 2009-02-06 06:21:56
Message-ID: 200902061151.56496.raju@linux-delhi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Friday 06 Feb 2009, Michael B Allen wrote:
> On Thu, Feb 5, 2009 at 10:59 PM, Rajesh Kumar Mallah
>
> <mallah(dot)rajesh(at)gmail(dot)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(at)kandalaya(dot)org http://kandalaya.org/
GPG: 78D4 FC67 367F 40E2 0DD5 0FEF C968 D0EF CC68 D17F
PsyTrance & Chill: http://schizoid.in/ || It is the mind that moves

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bart van Houdt 2009-02-06 09:41:04 Data length and data precision
Previous Message Stephan Szabo 2009-02-06 06:11:39 Re: Must I use DISTINCT?