Re: Couple of questions...
Sebastien Bigaret <[email protected]> 27 Apr 2004 21:02:40 +0200
| Newsgroups | gmane.comp.python.modeling |
|---|---|
| Message-ID | <[email protected]> |
Mario Ruggier <[email protected]> wrote: > > Almost... because EXISTS applies to a independent subquery, while the other > > keywords are constraints on the current query. Would this be a possible source > > of confusion? > > > > What happens if we intermix these keywords, e.g. > > > > ec.fetch('Writer', 'books.publisher.numPages>50 > > AND (books.publisher.bizName IN ["P1","P2"]) > > AND NOT EXISTS(books.publisher.bizName NOT IN ["P1","p2"] ) ' > > > > to get the authors that have books with at least 51 pages as well as having > > published with both of P1 and P2 but with no one else. Would this work? There > > would be a simpler way to do this? > oops, sorry, just realized that's pretty silly. Lousy example... > Make that something like: > > ec.fetch('Writer', 'books.publisher.numPages>50 > AND (books.publisher.bizName IN ["P1","P2"]) > AND NOT EXISTS(books.publisher.country NOT IN ["c1","c2"] ) ' > > or so... Not a problem:) My idea of this is that everything should nicely play one w/ the other, or we'll lose most of the feature, so we should be able to intermix every keyword w/o problem. I'll play with this some day for sure. To be more precise, in our case (a fetchspec) EXISTS do apply to an independent query but this query is always bound to the original one: look at this: =# SELECT DISTINCT t0.ID, t0.LAST_NAME, t0.FIRST_NAME, t0.AGE, -# t0.FK_WRITER_ID, t0.BIRTHDAY -# FROM WRITER t0 -# WHERE NOT EXISTS (SELECT * FROM BOOK,WRITER,PUBLISHER (# WHERE WRITER.ID=t0.ID (# AND WRITER.ID=BOOK.FK_WRITER_ID (# AND BOOK.FK_PUBLISHER=PUBLISHER.ID (# AND PUBLISHER.BIZ_NAME!='P1'); the second WHERE clause binds the "independent query" to the first one with WRITER.ID=t0.ID. --> that's why I think this shouldn't be difficult to implement, but I need to experiment with nested EXISTS clause (I do not have enonugh sql knowledge to foresee the possible coming complications). BTW I'll will be mostly off for a week, not sure if I'll read email for that time, and I'll be back online for sure some day next week. -- Sébastien. ------------------------------------------------------- This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th! http://www.thinkgeek.com/freeshipping/?cpg297