I'm trying to get records using inner join, but the result I get is wrong.
Here is my code, in a view:
*{{for page in pages:}}page.name<br>
*
*{{for row in db( db.tag.id==db.page_tag.tag_id,
db.page_tag.page_id==page.id ).select():}}{{=row.tag.name+str(page.id)}}
{{pass}}<br>
*
*{{pass}}
*
The tables page and tag are in a many-to-many relation with the table
page_tag. Since I'm looping each page in the outer loop, I want to find all
of each page's tags. Each row of page_tag belongs to one tag(and one page),
so it has a one-to-many relation to the tagtable, right?
Now, I want to inner join tag with page_tag, but select only those rows
which has page_id==page.id. Is this query correct for that purpose? What am
I doing wrong?
*db(*
* db.tag.id==db.page_tag.tag_id, # do the JOIN*
* db.page_tag.page_id==page.id # do the WHERE*
*).select()*
--
---
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/groups/opt_out.