If you're just fetching a single request at a time, you can also do a recursive select (see http://web2py.com/book/default/chapter/06#Recursive-selects): request = db(db.requests.id==3).select().first() description = request.product.description This is inefficient for multiple records (requires a separate database select for each record), though, so in that case, use a join as described below. Anthony
On Thursday, July 28, 2011 9:29:59 AM UTC-4, Cliff wrote: > Antonio, check out these references: > > http://www.web2py.com/book/default/chapter/06#Logical-Operators > http://www.web2py.com/book/default/chapter/06#One-to-Many-Relation > http://www.web2py.com/book/default/chapter/06#Many-to-Many > > Assuming 'db.requests.product' is a foreign key to your products > table, this should work: > > db((db.requests.product==db.products.id) & > (db.products.id==3)).select(db.requests.whatever, > db.products.whatever, ...) > > For clarity, in case anyone else should ever have to maintain the > code, it would be helpful if you renamed 'db.requests.product' to > 'db.requests.product_id' > > > > > On Jul 28, 9:05 am, António Ramos <[email protected]> wrote: > > this > > db(db.requests.product==*db.products.id*==3).select() > > > > returns all field from *product* table only > > > > this > > db(db.products.id==*db.requests.product*==3).select() > > > > returns all field from *requests* table only > > > > What is the logic? > > > > and if i want all record from both tables? > > > > thank you > > António

