belongs to one table but not the other ...

25 views
Skip to first unread message

Vlad

unread,
Jul 14, 2020, 11:12:53 PM7/14/20
to web2py-users
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?

Andrew Rogers

unread,
Jul 15, 2020, 2:40:08 AM7/15/20
to web2py-users
Try adding a '~' in front of it.

db(~(db.cart.id.belongs(another_table_select))).select(db.cart.id)

Eliezer (Vlad) Tseytkin

unread,
Jul 15, 2020, 10:51:46 AM7/15/20
to web...@googlegroups.com
Thank you!

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/t07RuFIU8Ok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2e765687-25d1-4ff4-9c1c-a4d9c34ddd2fo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages