you have to make a join:

rows=db(query)(db.dogs.owner==db.users.id).select()
for row in rows: print row.dog.name, row.users.name

we tend to use singular for table names.

On Oct 4, 12:10 am, Manoj <[email protected]> wrote:
> if i have following code
>
> db.define_table(
>     'users',
>     Field('name'),
>     Field('email')
>     )
>
> # ONE (users) TO MANY (dogs)
>
> db.define_table(
>     'dogs',
>     Field('owner_id', db.users),
>     Field('name'),
>     Field('type'),
>     Field('vaccinated', 'boolean', default=False),
>     Field('picture', 'upload', default=''),
>     )
>
> and i want to query dog for his owner's attributes how should I get
> it ? If i use "represents" it will return only 1 attribute? am i
> correct ?
>
> dogs.owner.name
> dogs.owner.email
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to