I agree with what Simon said, and want to point out that he is assuming that that Foo.bar is a relationship of Foo to Bar based on Foo.bar_id = Bar.id
But you should understand that these are two completely different queries AND you haven't described your model at all. session.query(Foo).filter(Foo.bar_id != bar.id) session.query(Foo).filter(Foo.bar != bar) If Simon's assumption is wrong, you need to share your actual model. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.