Thank you Richard, your expression returns ROWS and can't be used in 
SQLFORM.grid. When I removed the last select 

db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id))

then I get 

File "E:\web2py 2.9.12\gluon\sqlhtml.py", line 2139, in grid
 field_id = tables[0]._id
IndexError: list index out of range


Dave, the tables are related. e.g. the table "assigned" has a field "computer" 
of type db.pc



Thanks,
PT


On Friday, September 4, 2015 at 3:23:47 PM UTC-5, Dave S wrote:
>
> I'm puzzled about the why ...
>
> On Friday, September 4, 2015 at 12:42:32 PM UTC-7, Richard wrote:
>>
>> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id
>> )).select(db.pc.ALL)
>>
>> Richard
>>
>>
>>
>> On Fri, Sep 4, 2015 at 3:35 PM, P T <[email protected]> wrote:
>>
>>>
>>> Hello Forum,
>>>
>>> Please help me in getting the equivalent DAL query for the following SQL 
>>> query. I intend to pass this on to SQLFORM.grid
>>>
>>> Select * from db.pc where db.pc.id not in (select unique 
>>> db.assigned.computer from db.assigned)
>>>
>>>
> when there's no reference between tables:
>
>
>  
>
>> Web2Py Version
>>> 2.9.12-stable+timestamp.2015.02.15.23.04.25
>>> (Running on Rocket 1.2.6, Python 2.7.9) 
>>>
>>> db.define_table('staff',
>>>                 Field('name', 'string', unique=True),
>>>                format='%(name)s')
>>>
>>> db.define_table('pc',
>>>                 Field('csi', 'string', unique=True),
>>>                format='%(csi)s')
>>>
>>> db.define_table('assigned',
>>>                 Field('staff', db.staff),
>>>                 Field('computer', db.pc))
>>>
>>> Thanks,
>>> PT
>>>
>>>
>>
> (see, no "Field('name', 'reference othertable', ...)")
>
> /dps
>  
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to