On Apr 16, 2007, at 5:55 AM, ml wrote:

>
> Hi!
>
> Let's have:
> ---------------------
> users_table = Table("users", metadata,
>     Column("id", Integer, primary_key=True),
>     Column("user_name", String(16))
> )
>
> addresses_table = Table("addresses", metadata,
>     Column("id", Integer, primary_key=True),
>     Column("addr", String(100))
> )
>
> _ua = Table("_ua", metadata,
>     Column("id_user", Integer, ForeignKey("users.id")),
>     Column("id_addr", Integer, ForeignKey("addresses.id"))
> )
>
> mapper(Address, addresses_table)
> mapper(User, users_table, properties = {
>         "addresses" : relation(Address, cascade="all, delete-orphan",
> secondary=_ua,
>                                backref=backref("user")),
>     }
>   )
>
> ---------------------
>
> How can I select user's addresses when I know only his id? And I don't
> want to select the user first.

session.query(Address).join("user").select(User.c.id==<the user id>)




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to