1

select category_id, (select category.name from category where category.id = category_id ) as category_name from ( select distinct category_id as category_id from model join category on ( category.id = model.category_id) ) as R

... self.current_session.query(Model.category_id).join(Category).distinct()

But how to know category_name ?

1
  • Step 1. Format your code using {}. Step 2. Clarify your question with -- perhaps -- the actual error message you're actually getting. Commented Feb 2, 2011 at 12:26

1 Answer 1

1
for model, category in self.current_session.query(Model, Category).join(Category).distinct(): print model.category_id, category.name 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.