Hi Manakel, I've been playing with joins and found this reference to be very helpful.
Perhaps it may help you too: http://web2py.com/book/default/chapter/06#Inner-Joins Based on your code, I think you are probably looking for "recursive selects" in web2py (vs "related" in django). It is referenced here: http://web2py.com/book/default/chapter/06#Recursive-selects I don't think you can use db.budgets.type.name within .select(), but web2py can recursively select the item for you if you use >> budget_list.type.name On Dec 1, 10:40 pm, Manakel <[email protected]> wrote: > Hello, > > I have a model with 2 tables with a "reference" relationship between > the two. > => the Budget has a type and the name/attributes of this type are > defined in the budget_types table. > > Now in a query on the budget table i would like to retrieve the name > of the Budget type and not the Budget Type id. > > My model is: > > db.define_table('budget_types',Field('name','string'),Field('description',' > string'),format='% > (name)s') > db.define_table('budgets',Field('name','string'),Field('monthly_amount','do > uble'),Field('type',db.budget_types),Field('view_order','integer'),format=' % > (name)s') > > My current query is : > > budget_list= > db().select(db.budgets.id,db.budgets.name,db.budgets.type,db.budgets.monthl > y_amount,orderby=db.budgets.view_order).as_list() > > I was thinking about doing > budget_list= > db().select(db.budgets.id,db.budgets.name,db.budgets.type.name,db.budgets.m > onthly_amount,orderby=db.budgets.view_order).as_list() > > but it fails. > > I guess i could do this with an explicit join but i thought there was > a "related" feature like in django ;-)

