Update your join to use SQLRelatedJoin instead of just RelatedJoin to the
the filter() function that I'm pretty sure is missing from RelatedJoin.
Then you'd do something like:
c = Category.get(1)
c.contacts.filter(IN(Contact.q.id, [1,2,3]))
On Tue, 19 Jun 2007, Jim Steil wrote:
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss