DAL join field access

20 views
Skip to first unread message

lucas

unread,
Sep 10, 2022, 7:47:20 AMSep 10
to web2py-users
hello one and all,

you know how when you do a select join and the records come back where you have to access the field values by like db.table1.id or db.table2.last_name?  and i know that under the select we can do like db.table1.ALL and db.table2.last_name, but we still have to access the field values by like db.table1.id or db.table2.last_name?

is there a way to collapse the fields so that we can just use id or last_name, especially when we're certain that the fields are unique when we collapse when we specify the fields under the select?

thank you in advance, lucas

Massimiliano

unread,
Sep 10, 2022, 12:43:30 PMSep 10
to web...@googlegroups.com
Hi,

I'm not sure to have understand correctly your question, but maybe you need to use aliases:

fields = [
    db.table1.id.with_alias('id'),
    db.table2.last_name.with_alias('last_name')
]

db(yourquery).select(*fields)




--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/cfb499ac-7e22-4bfa-b702-99ac5d8924d5n%40googlegroups.com.


--
Massimiliano

lucas

unread,
Sep 10, 2022, 10:57:43 PMSep 10
to web2py-users
yes, that worked perfectly.  thank you massimiliano.  lucas
Reply all
Reply to author
Forward
0 new messages