I need to execute multiple lines of SQL in web2py, something like this:

    db.executesql("set @num := 0, @type := '';")\
    rows = db.executesql("select type, variety, price\
    from (\
       select type, variety, price,\
          @num := if(@type = type, @num + 1, 1) as row_number,\
          @type := type as dummy\
      from fruits\
      order by type, price\
    ) as x where x.row_number <= 2;")

But, when I run it I don't get expected results in web2py (the variables 
don't get initialized), even though it works from the mysql console. What 
am I doing wrong?

They don't work, even if I put the variable initialization in the same 
call. This piece of SQL is from here: 
http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

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