On Sun, Feb 24, 2008 at 5:35 PM, dundeemt <[EMAIL PROTECTED]> wrote:
>
>  Given:
>
>  class Vendors(Entity):
>     using_options(tablename="vendors")
>
>     vendorid = Field(Unicode, primary_key=True)
>     vendname = Field(Unicode)
>     items = ManyToMany('Items')
>
>  class Items(Entity):
>     using_options(tablename="items")
>
>     itemnmbr = Field(Unicode, primary_key=True)
>     itemdesc = Field(Unicode)
>     vendors = ManyToMany('Vendors')

>
>  How do I construct the query to select those Vendors that have no
>  Items
>   vnd.items == []
>  or the equivalent of the sql statement:
>  SELECT *
>   FROM vendors
>   WHERE vendorid NOT IN (
>     SELECT vendors_vendorid
>       FROM vendors_items__items_vendors)

I think:
    Vendors.query.filter_by(items=[])
should do.

If that doesn't work, try:
    Vendors.query.filter(Vendors.items == [])

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to