For example, I have this database structure:
db.define_table('sections',
Field('title', 'string')
)
db.define_table('threads',
Field('title', 'string'),
Field('section_id', db.sections),
)
How can I get all sections and by 1 random thread per each section?
This works:
rows = db(db.sections.id>0).select(db.sections.id, db.threads.id,
left=db.threads.on(db.threads.section_id==db.sections.id),
distinct=db.sections.id)
but it gets not random threads.
How to get random?
And how to get 2 or 3 threads per each section?