Wondering if the "*belongs*" operator is what you are looking for?
db((db.Relation.id == db.Role.relationid) &
(db.Role.value.*belongs*(['DMV','Suggestion'])).select()
Details here:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#belongs
________________________________________
Kiran Subbaraman
http://subbaraman.wordpress.com/about/
On Fri, 26-12-2014 1:09 PM, Alex Glaros wrote:
I have a parent (Relationship) table and a child (Role) table.
Some of the child (Role) records contain the value "DMV", and other
child (Role) records contain the value "Suggestion".
I want to find a parent (Relationship) table that has Role children
that contain both of the above values. In other words, Relationship
has both a child that has "DMV", and another child that has the value
"Suggestion".
The problem is that I can't use the "or" operator because both
children have to exist with the same parent. I can't use the "&"
operator because the values are mutually exclusive in the same child
record.
To re-describe the question, here is an example of how it might be
solved using pseudo code.
|
FirstPass=db(Relation.id == Role.relationId) & (Role.value=="DMV")
SecondPass=db(Relation.id == Role.relationId) & (Role.value=="Suggestion")
ThirdPass=(FirstPass.relationId==SecondPass.relationID)
Now in ThirdPass I have only the Relation records that have both "DMV"
and "Suggestion" Role children.
|
Thanks,
Alex Glaros
--
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 web2py+unsubscr...@googlegroups.com
<mailto:web2py+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
--
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.