Re: [sqlalchemy] distinct query

2010-03-19 Thread Sebastian Elsner
Hello, qry = session.query(AssetCategory).join(Asset).join(Shot).filter(Shot.id==1).distinct() this one already did the trick. qry = qry.filter(Shot.id==shot_id_of_interest) what did you add this for? The results seem to be identical... that generates SELECT DISTINCT AssetCategory.id

[sqlalchemy] distinct query

2010-03-18 Thread Sebastian Elsner
Hello, I am stuck here with a query, it't not too complicated I think, but I dont get it... I have three Class/table mappings: Shots, Assets, which belong to a Shot (1:n) and AssetCategories, which are owned by Assets (n:1) The objective is: For a given shot instance get all distinct

Re: [sqlalchemy] distinct query

2010-03-18 Thread Mike Conley
Did you try qry = session.query(AssetCategory).join(Asset).join(Shot).filter(Shot.id==1).distinct() qry = qry.filter(Shot.id==shot_id_of_interest) that generates SELECT DISTINCT AssetCategory.id AS AssetCategory_id FROM AssetCategory JOIN Asset ON AssetCategory.id = Asset.category_id JOIN Shot