I've got a Contact class:

class Contact(SQLObject):
    class sqlmeta:
        style = Style(longID=True)
        idName = 'contactId'

    customerNumber = IntCol()
    coopId = IntCol()
    companyName = UnicodeCol(length=50)
    ...
    categories = RelatedJoin("Category", 
intermediateTable="contactCategory",
                         joinColumn="contactId", otherColumn="categoryId")

and a Category class:

class Category(SQLObject):
    class sqlmeta:
        style = Style(longID=True)
        idName = 'categoryId'

    name = UnicodeCol(length=50)
    description = UnicodeCol()
    contacts = RelatedJoin("Contact", intermediateTable="contactCategory",
                         joinColumn="categoryId", otherColumn="contactId")


I've got 3 categories defined and want to get a list of the contacts 
that belong to either Category 1 or Category 3.  To do this with SQL, 
I'd do the following:

SELECT * FROM contact WHERE contactId IN (SELECT contactId FROM 
contactCategory WHERE categoryId IN (1,3))

Is there a good sqlobject way to do this?

    -Jim

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to