Try adding a '~' in front of it. db(~(db.cart.id.belongs(another_table_select))).select(db.cart.id)
See: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=lazy#Logical-operators On Wednesday, 15 July 2020 13:12:53 UTC+10, Vlad wrote: > > I have the following select to get the ids that are in one table, also > belonging to another table: > > db(db.cart.id.belongs(another_table_select)).select(db.cart.id) > > I can't figure out how to do just the opposite - to get the ids that do > NOT belong to the other table, i.e. exist in one table but not the other. > How do I specify opposite of "belongs" in such a query? > . > -- 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 web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2e765687-25d1-4ff4-9c1c-a4d9c34ddd2fo%40googlegroups.com.