Hi,
Is it possible to create alias which would reference only a part of the 
table? 

Check the example code below. I would like to create the "host" alias so 
that it would include the condition role=='host'. Then I wouldn't have to 
specify this condition every time I use the alias.

db.define_table('party',
    Field('place'))


db.define_table('participant',
    Field('party_id', 'reference party'),
    Field('name'),
    Field('role'))    

db.party.insert(place="Jane's home")

db.participant.insert(name='Jane',party_id=1,role='host')
db.participant.insert(name='George',party_id=1,role='organizer')
db.participant.insert(name='John',party_id=1,role='guest')
db.participant.insert(name='Mary',party_id=1,role='guest')


*host = db.participant.with_alias('host')**organizer **= 
db.participant.with_alias('organizer')*

rows = db().select(
        db.party.place,
        host.name,
        organizer.name,
    left=(
        host.on((host.party_id==db.party.id) & *(host.role=='host'**)*),
        organizer.on((organizer.party_id==db.party.id) &* 
(organizer.role=='organizer'**)*)
    ))


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

Reply via email to