Hi Mike, On 7/29/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > > cats = self.meta.tables['wp_categories'] > > posts = self.meta.tables['wp_posts'] > > post2cat = self.meta.tables['wp_post2cat'] > > q = self.session.query(WordpressPost) > > q = q.filter(WordpressPost.c.status=='publish') > > q = q.filter(WordpressCategory.c.slug=='sitenews') > > q = q.filter(post2cat.c.post_id==posts.c.ID) > > q = q.filter(post2cat.c.category_id==cats.c.cat_ID) > > > > you should be able to > > session.query(WordpressPost).filter_by(status='publish').join > ('categories').filter_by(slug='sitenews')
It works, thanks a lot! Actually, I was playing with various automatic joins but my mistake was that I was trying to use table-level joins. I haven't realized I could use 'categories' relation defined at the mapper level. Best, Max. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---