Got it ! Thanks a lot!!
My case was actually not belongs (not in) and I can do it by adding
"~" at the beginning of query.
def index():
requests = db()._select(db.PDTFF.FFDNO)
query = db.SDTH2P01.H2DNO.belongs(requests)
orders=db(~query).select(orderby=[db.SDTH2P01.H2JCSC,db.SDTH2P01.H2TRD1])
return dict(orders=orders)
On Nov 3, 2:57 pm, Richard Vézina <[email protected]> wrote:
> http://web2py.com/book/default/chapter/06?search=belong#belongs
>
> Richard
>
>
>
>
>
>
>
> On Thu, Nov 3, 2011 at 2:35 PM, Omi Chiba <[email protected]> wrote:
> > I'm using DB2 and I can do the sql on AS400 like this. This is only
> > selecting the data from SDTH2P01 which value is not existing in PDTFF.
>
> > SELECT * FROM SPDTHKU/SDTH2P01 WHERE
> > H2DNO NOT IN (SELECT FFDNO FROM SPDTHKU/PDTFF)
>
> > Can we do it on web2py and how ?
>
> > My contoller
> > ---------------------------------------------------------
> > def index():
> > query = db.SDTH2P01.H2DNO<>''
>
> > orders=db(query).select(orderby=[db.SDTH2P01.H2JCSC,db.SDTH2P01.H2TRD1])
> > return dict(orders=orders)