I do not think so.
On Nov 16, 10:37 am, LightOfMooN <[email protected]> wrote: > By this way we get just 3 records at all. But I need to get ALL > sections, and by 3 thread per section. > > So, I need a query to make this structure: > > section1 > thread1 > thread4 > section2 > thread5 > section3 > thread7 > thread8 > thread9 > > It can be done by many queries like: > sections = db(db.sections.id>0).select() > for section in sections: > threads = > db(db.threads.section_id==section.id).select(orbderby='<random>',limitby=(0 > ,3)) > > But there are too many queries. Is there a way to get it at one or two > queries? > > On 16 ноя, 19:35, Massimo Di Pierro <[email protected]> > wrote: > > > > > > > > > select(...,orbderby='<random>',limitby=(0,3)) > > > On Nov 16, 2:27 am, LightOfMooN <[email protected]> wrote: > > > > 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?

