[sqlalchemy] Re: M:N select

2009-04-30 Thread Tomáš Drenčák
I found out the solution by explicitly adding join condition: eq1 = ad_equipment_table.alias() eq2 = ad_equipment_table.alias() e1 = equipment_table.alias() e2 = equipment_table.alias() ad_table.join(eq1, join_condition(ad_table, eq1)).join(e1, join_condition(eq1, e1)).join(eq2,

[sqlalchemy] Many to many relation select

2009-04-29 Thread Tomáš Drenčák
Hi, I've got table Ad which has many to many relation with table Equipment through table ad_equipment. I want to select all ads which have all equipments in the list. Corresponding SQL query will look like this: select * from ad where ad.id in ( select id from ad join

[sqlalchemy] Re: Many to many relation select

2009-04-29 Thread Tomáš Drenčák
I've forgotten to attach the file with tables... On Wed, Apr 29, 2009 at 4:12 PM, Tomáš Drenčák to...@drencak.com wrote: Hi, I've got table Ad which has many to many relation with table Equipment through table ad_equipment. I want to select all ads which have all equipments in the list