Re: Queries against to-many relationships with 'NOT' subexpressions

From: Aristedes Maniatis (ar..aniatis.org)
Date: Tue Aug 24 2010 - 23:45:33 UTC

  • Next message: patrick.maywe..i-de.com: "Antwort: INSERT with raw_sql_query returns error"

    On 25/08/10 12:57 AM, Victor Antonovich wrote:
    > Hello!
    >
    > 24.08.2010 16:05, Aristedes Maniatis wrote:
    >
    >> You need to create an outer join.
    >>
    >> http://cayenne.apache.org/doc/path-expressions.html
    >>
    >
    > Thanks for the response. AFAIR outer join can widen query results, but I need to narrow them excluding joining of group records with same ID.
    >
    > Could You explain usage of outer join for such case?

    On the page I referenced you can see two important ideas. A split join (aliased path) will let you create two different joins so that you can separate out your two parts of the query. And an outer join is usually what you need when you want to find the negation of a relationship. But that depends on whether you mean:

    1. find all records which are joined to records other than 'admin', OR
    2. find all records which are not joined to 'admin' (including records which aren't joined to anything)

    depending on which one you are after will determine how you need to build this query

    Ari

    -- 
    -------------------------->
    Aristedes Maniatis
    GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
    



    This archive was generated by hypermail 2.0.0 : Tue Aug 24 2010 - 23:46:13 UTC