Marin Pranjic answered me on Facebook:

"You need 4 separate queries to select records for given board and you can 
sort them afterwards, using python. First you merge the records using 
itertools.chain, then you sort it using sorted(merged_records, key=lambda 
record: record.created_on). Something like that "


Em sábado, 5 de abril de 2014 11h33min36s UTC-3, Júlia Rizza escreveu:
>
> So I have this tables:
>
> if not "board" in db.tables:
> db.define_table("board",
> Field("title", label=T('Title')),
> Field("description", 'text', label=T('Description')),
> auth.signature,
> format = "%(title)s"
> )
>
> if not "text_type" in db.tables:
> db.define_table("text_type",
> Field("title", label=T('Title')),
> Field("body", 'text', label=T('Content')),
> Field("board", 'reference board', label=T('Board')),
> auth.signature,
> format = "%(title)s"
> )
>
> if not "url_type" in db.tables:
> db.define_table("url_type",
> Field("url", label=T('URL')),
> Field("board", 'reference board', label=T('Board')),
> auth.signature,
> format = "%(title)s"
> )
>
> if not "image_type" in db.tables:
> db.define_table("image_type",
> Field("upload_image", 'upload', label=T('Upload Image')),
> Field("board", 'reference board', label=T('Board')),
> auth.signature,
> format = "%(title)s"
> )
>
> if not "video_type" in db.tables:
> db.define_table("video_type",
> Field("url_video", label=T('Video URL')),
> Field("board", 'reference board', label=T('Board')),
> auth.signature,
> format = "%(title)s"
> )
>
> All the four last tables have a common field that references board. Now I 
> need to select all the records of this four tables that reference the same 
> board and sort them by the created_on field, like:
>
> board_id = int(request.args(0))
>
> topics = db((db.text_type.board == board_id)&(db.image_type.board == 
> board_id)&(db.video_type.board == 
> board_id)...).select(orderby=db.table.created_on)
>
> But it doesn't work and I don't understand why.
>

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