ehm... mine was an example. You can include in the select what you want 
from the animals table....

On Friday, August 9, 2013 12:36:11 AM UTC+2, dave wrote:
>
> is there another way to do it, because this replaces my db.zoo.tier field 
> with the id
>
> On Thursday, August 8, 2013 1:55:48 PM UTC-7, Niphlod wrote:
>>
>> you join them first and then you belong() on the type column.
>>
>> db(
>>     (db.zoo.tier == db.animals.id) &
>>     (db.animals.type.belongs(['test1', 'test2']))
>> ).select(db.zoo.ALL)
>>
>>
>> On Thursday, August 8, 2013 10:19:47 PM UTC+2, dave wrote:
>>>
>>> ok that works but I have one other question, how would I use the belongs 
>>> operator If I want to refer a field by a name for example
>>> instead of rows = db(db.zoo.tier.belongs([2, 3])).select()  I want to do 
>>> this
>>>                rows = db(db.zoo.tier.belongs(["test 2", "test 
>>> 3"])).select()  ?
>>>
>>> On Thursday, August 8, 2013 12:51:12 PM UTC-7, Massimo Di Pierro wrote:
>>>>
>>>> This
>>>>
>>>> rows = db(db.zoo.tier == 2).select()
>>>>
>>>> is equivalent to
>>>>
>>>> rows = db(db.zoo.tier.belongs([2])).select()
>>>>
>>>> you can do
>>>>
>>>> rows = db(db.zoo.tier.belongs([2, 3])).select()
>>>>
>>>>
>>>> On Thursday, 8 August 2013 14:28:47 UTC-5, dave wrote:
>>>>>
>>>>> I have two tables defined as follows
>>>>>
>>>>> db.define_table('animals', 
>>>>>             Field('type'),
>>>>>             format='%(type)s')
>>>>>
>>>>> db.define_table('zoo', 
>>>>>             Field('name'), 
>>>>>             Field('tier', 'reference animals'),
>>>>>             format='%(name)s' 
>>>>>             ) 
>>>>>
>>>>> field type is a column with values like, test 1, test 2, test 3
>>>>> now if I want to select all the records of table zoo with 'test 2' I 
>>>>> can do something like this 
>>>>>
>>>>> rows = db(db.zoo.tier == "2").select()
>>>>>
>>>>> but why can't I do something like 
>>>>> db(db.zoo.tier.contains("2")).select() or
>>>>> pass a list  ["2", "3"] to the contains operator to get all the 
>>>>> records of "test 2" and "test 3"? can you suggest another way of 
>>>>> implementing this?
>>>>>
>>>>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to