Oops. 

db(db.table.refrence == db.refrencedtable.id).select(db.table.ALL, orderby=
db.refrencedtable.Field)

mind that there have to be records referencing each other, i.e. 

db.refrencedtable
*1*, aaa
*2*, bbb
*3*, ccc

db.table
1, 'title1', *1*, ...
2, 'title 2', *1*, ...
3, 'title 3', *1*, ....
4, 'title 4', *2*, ....

i.e. bold numbers in table needs to be the same of ids used in 
refrencedtable

On Friday, March 1, 2013 4:58:04 PM UTC+1, BlueShadow wrote:
>
> when I change the line in default.py(example from my first post) to: row = 
> db(db.table.refrence == db.refrencedtable.Field).
> select(db.table.ALL, orderby=db.refrencedtable.Field)
> if I do a print row or use row in the view somehow it is blank/empty
>
>
> On Friday, March 1, 2013 4:32:31 PM UTC+1, Niphlod wrote:
>>
>> what does it mean "an empty variable" ?
>>
>> On Friday, March 1, 2013 4:04:47 PM UTC+1, BlueShadow wrote:
>>>
>>> thanks Niphlod for this it sounds really good but unfortunatly I get an 
>>> empty variable when I do this.
>>> Richard i don't really understand what you like to say.
>>>
>>>
>>> On Wednesday, February 27, 2013 10:28:12 PM UTC+1, Niphlod wrote:
>>>>
>>>> you should join them and then do the ordering. auto-references are a 
>>>> nice facility but comes with a price: you can't use them just like if your 
>>>> records were in a single table to do a select or an update....
>>>>
>>>> db(db.table.refrence == db.refrencedtable.Field).select(db.table.ALL, 
>>>> orderby=db.refrencedtable.Field)
>>>>
>>>> On Wednesday, February 27, 2013 10:17:28 PM UTC+1, BlueShadow wrote:
>>>>>
>>>>> Hi,
>>>>> I got two Tables lets call them table and referencedtable. table has a 
>>>>> field which is a reference to referenced table. Now I like to select all 
>>>>> entries from table and order them by a field in the referenced table. In 
>>>>> my 
>>>>> opinion it should work like this: 
>>>>> #defauft.py
>>>>>  rows=db().select(db.table.ALL, orderby=db.table.reference.Field)
>>>>>
>>>>> #db.py
>>>>>
>>>>> db.define_table('refrencedtable',
>>>>>     Field('Field',length=512)
>>>>>     )
>>>>>
>>>>> db.define_table('table',
>>>>>     Field('Title',length=1024),
>>>>>     Field('refrence',db.refrencedtable),
>>>>>     Field('Test','upload')
>>>>>     )
>>>>> but when I do this I get an error that referncedtable has no Field 
>>>>> called Field.
>>>>>
>>>>>

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to