[web2py] Re: Simplifying a SQL statement

2011-11-20 Thread Adrian Edwards
You're right it turned out that wasn't quit the solution I needed. After some testing I was able to get it working with the following command. entries = db(db.entries.user.belongs(db(db.event_users.event==event_id).select())).select(groupby=db.entries.user, orderby=~db.entries.value) I'm now

[web2py] Re: Simplifying a SQL statement

2011-11-20 Thread Cliff
If not working in the console, "print db._lastsql" will output the sql string to the terminal session where you started web2py, assuming you started it without the gui. Otherwise I think the gui has a little field to display outputs. On Nov 20, 3:42 pm, villas wrote: > Hi Adrian > Good that you

[web2py] Re: Simplifying a SQL statement

2011-11-20 Thread villas
Hi Adrian Good that you are making progress, even though it doesn't look like the SQL would be equivalent to me. However, just in case you didn't already know this tip, I have so often found it useful to see what SQL statement is being generated by prefixing '_' in front of select, eg db(que

[web2py] Re: Simplifying a SQL statement

2011-11-20 Thread Adrian Edwards
Figured it out. Basically what I was trying to do was the following select SELECT entries FROM entries, event_users WHERE event_users.event == event_id Which I translated into entries_query = db.event_users.event == event_id entries = db(entries_query).select(db.entries.ALL, groupby=