you can do that with
>
> all_courses = db(db.courses.id>0)._select(db.courses.memberid)
> all_members_not_in_courses = db(~db.members.id.belongs(all_courses))
>
>
>>
Would such an approach be computationally expensive particularly if the 
number of rows in courses is high? Perhaps the following raw SQL expression 
would be more efficient:

from gluon.dal import Expression
all_members_not_in_courses = db((db.members.id>0)&Expression('NOT EXISTS 
(SELECT courses.memberid FROM courses WHERE 
courses.memberid=members.id)')).select()


-- 
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/groups/opt_out.

Reply via email to