Maybe the web2py book could help you:

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=with_alias#Self-Reference-and-aliases


Il giorno lunedì 31 luglio 2017 00:19:11 UTC+2, Brendan Barnwell ha scritto:
>
> On Monday, May 29, 2017 at 11:30:53 PM UTC-7, Brendan Barnwell wrote:
>>
>> When running queries that do joins, I often find the format of the result 
>> somewhat cumbersome, with its nested structures representing the different 
>> tables in the join.  If I were writing the query in raw SQL, I would 
>> probably use "AS" clauses to select just the columns that I want, with 
>> simple "top-level" names.  Something like
>>
>> Select Table1.foo as stuff, Table2.bar as blah from Table1, Table2 ...
>>
>> Is there a way to do this with Web2py?  It would seem natural to specify 
>> this inside the select call, something like
>>
>> db(db.Table1.foo=db.Table2.foo).select(db.Table1.foo.alias('foo'), 
>> db.Table2.bar.alias('blah'))
>>
>
> Any ideas on this?  I continue to be especially frustrated at having to 
> unpack the nested structure that occurs when I select using a join.  I want 
> to be able to easily "flatten" the structure into a single list of column 
> names, rather than the existing structure where column names are nested 
> inside table names.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to