On Friday 06 Feb 2009, Michael B Allen wrote: > On Thu, Feb 5, 2009 at 10:59 PM, Rajesh Kumar Mallah > > <mallah.raj...@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 r...@kandalaya.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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql