m1 = db.messages
m2 = db.messages.with_alias('m2')
messages = db(m2.timesent==None).select(m1.ALL, left=m2.on((m1.fromid==m2.
fromid)&(m1.toid==m1.toid)&(m1.timesent<m2.timesent)), orderby=~m1.timesent)

will give you the latest messages from each user to another user by 
descending time.

If you want just one user's messages do

messages = db((m2.timesent==None)&(m1.fromid==auth.user.id)).select(m1.ALL, 
left=m2.on((m1.fromid==m2.fromid)&(m1.toid==m1.toid)&(m1.timesent<m2.
timesent)), orderby=~m1.timesent)

Denes.



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

Reply via email to