[sqlalchemy] Re: SQL Question - Find missing records with Outer Join

2008-05-29 Thread EricHolmberg
some_alg = sess.query(Alg).get(8) sess.query(Email).filter(~Email.threads.any(Thread.alg==some_alg)) The clause Thread.alg=some alg *should* just generate the clause thread.algid=8...it shouldn't pull in the alg table at all since its not needed for many-to-one comparison. That works

[sqlalchemy] Re: SQL Question - Find missing records with Outer Join

2008-05-28 Thread Michael Bayer
On May 28, 2008, at 8:24 PM, EricHolmberg wrote: CREATE TABLE alg (id INT NOT NULL, name VARCHAR(32)); CREATE TABLE email (id INT NOT NULL, subject VARCHAR(256)); CREATE TABLE thread (id INT NOT NULL, algid INT, emailid INT); This is great, I get my list of emails that don't have any