assuming a reasonable mapping (i.e. the m2m example in the datamapping docs)
session.query(Node).select(and_( nodes.c.id.in_(select([group_nodes.c.node_id], group_nodes.c.group_id==1, correlate=False), nodes.c.id.in_(select([group_nodes.c.node_id], group_nodes.c.group_id==2, correlate=False)) )) the query would probably be better expressed as a couple of JOINs to aliases of the group_nodes table instead of using IN On Apr 23, 2007, at 5:23 PM, Karthik Krishnamurthy wrote: > I don't have a very good idea about that. But I do know the query I > have used works. Still hoping > somebody has an idea of how to achieve that using the ORM. Or maybe > I should be using a select > and then mapping it. > > /kk > > On 4/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED] > > wrote: > > > sorry for my somewhat stupid question, isn't this possible to be done > via joins instead of subselects? > > On Friday 20 April 2007 03:21:35 Karthik Krishnamurthy wrote: > > Hi, > > Given the application in the attached file how do I query for > > nodes that belong to groupNode id's 1 AND 2. > > > > /kk > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---