Sorry, it took me a while to understand your question. But you actually 
have a very good question. Here is how you do it:

db=DAL()
db.define_table('auth_user',
                Field('name'))
db.define_table('message',
                Field('to_user',db.auth_user),
                Field('from_user',db.auth_user))

max = db.auth_user.insert(name="Max")
ashraf = db.auth_user.insert(name="Ashraf")
db.message.insert(to_user=ashraf,from_user=max)

sender = db.auth_user.with_alias('sender')
receiver = db.auth_user.with_alias('receiver')

rows = 
db((db.message.from_user==sender.id)&(db.message.to_user==receiver.id)).select()

for row in rows: print row.sender.name,'->',row.receiver.name




On Thursday, 19 July 2012 17:57:03 UTC-5, Ashraf Mansour wrote:
>
> Hi,
>
> The first table has two fields:
>
> *  from_user , db.auth_user*
> *  to_user , db.auth_user*
>
> both are referencing db.auth_user.
>
> How to get the list of records in the first table with the corresponding 
> first_name of the two fields?
>
> I am confused, because I don't know how to differentiate the two field --- 
> db.auth_user.name for the two fields.
>
> Regards,
>
> Ashraf
>

-- 



Reply via email to