LaDarrius, the point to have the join is to get the tag properties in one
query. Your solution only returns the tag id's.
Annet, tweaking your solution made it work:
*dbTags =
db((db.product_tag.product==row.product.id)&(db.product_tag.tag==db.tag.id)).select(db.tag.ALL)*
Thanks for your help guys!
Den tisdagen den 3:e juni 2014 kl. 10:54:52 UTC+2 skrev Robin Manoli:
>
> Hey, I have a many-to-manyrelation, such as:
>
>
>
>
>
> *db.define_table('product_tag', Field('product', 'reference
> product'), Field('tag', 'reference tag'), )*
> Now when I would like to select the tags for a product with the id
> row.product.id, I came up with this, so that I don't have to do an extra
> query for each tag name:
> *dbTags = db(db.product_tag.product==row.product.id
> <http://row.product.id>).select(join=db.tag.on(db.tag.id
> <http://db.tag.id>==db.product_tag.tag))*
>
> Now when I iterate dbTags, I don't need to reference the product_tag
> table, but only the tag table. I would like to iterate such as
>
> *for tag in dbTags: print tag.name <http://tag.name> # instead of
> current tag.tag.name <http://tag.tag.name>*
>
> Thanks for your help!
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.