this is approached using joins as described in the ORM tutorial at http://docs.sqlalchemy.org/en/rel_0_7/orm/tutorial.html#querying-with-joins .
If you'd like to present a specific A to Query without filtering for A rows, you can use with_parent(), see the last example in http://docs.sqlalchemy.org/en/rel_0_7/orm/tutorial.html#common-relationship-operators . On Jul 1, 2012, at 3:42 PM, Diego wrote: > Hi, > > Say I have two entities A and B, that have a many to many relationship > between them. > > Now I'd like to get all Bs from a given A, ordered by some attribute of B. > Something like > > select B from A order by B.attr desc > > How do I express that query using the ORM? > > Thanks in advance, > Diego > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sqlalchemy/-/MUvsZ0Mgu78J. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.