Given

rows1 =db(db.table1).select(orderby=~db.table1.added_on, limitby=(0,5))
rows2 =db(db.table2).select(orderby=~db.table2.added_on, limitby=(0,5)) 

you can do

rows = rows1|rows2 # if you want to discard repeated values
rows = rows1&rows2 # if you do not want to discard repeated values

rows = rows.sort(lambda row: row.added_on)

then return dict(rows=rows)

On Sunday, 6 May 2012 20:08:18 UTC-5, CtrlSoft wrote:
>
> hi, i have 2 tables both has "added_on"  field
>
> i need last 'n'(lets assume n=5) rows from both tables ordered by 
> added_on. it can be 1 from first table and 4 from second or 2|3
>
> rows1 =db(db.table1).select(orderby=~db.table1.added_on, limitby=(0,5))
> rows2 =db(db.table2).select(orderby=~db.table2.added_on, limitby=(0,5)) 
>
> i need smth like this
>
>  rows = rows1+rows2 
>  rows->orderby(added_on)
>
>  return dict(first 5 row in rows)
>
> how to do this in a smarter way?
>
>
>

Reply via email to