Hi:
I'm having trouble formulating the right query for my circumstance.
Here is the SQL statement I'm trying to build:
SELECT * FROM qucm WHERE plantId IN (SELECT plantId FROM userPlant WHERE
userId = 2)
Here is my model:
class Plant(SQLObject):
class sqlmeta:
style = Style(longID=True)
idName = 'plantId'
plantNumber = IntCol()
name = UnicodeCol(length=50)
initials = UnicodeCol(length=3)
active = BoolCol(default=True)
users = RelatedJoin('User', intermediateTable='userPlant',
joinColumn='plantId', otherColumn='userId')
products = RelatedJoin('Product', intermediateTable='formula',
joinColumn='plantId', otherColumn='productId')
qucms = MultipleJoin('Qucm', joinColumn='plantId')
class User(SQLObject):
class sqlmeta:
table = "tg_user"
user_name = UnicodeCol(length=16, alternateID=True,
alternateMethodName="by_user_name")
email_address = UnicodeCol(length=255, alternateID=True,
alternateMethodName="by_email_address")
display_name = UnicodeCol(length=255)
password = UnicodeCol(length=40)
brillLogon = UnicodeCol(length=10, dbName='brillLogon')
active = BoolCol()
created = DateTimeCol(default=datetime.now)
# groups this user belongs to
groups = RelatedJoin("Group", intermediateTable="user_group",
joinColumn="user_id", otherColumn="group_id")
plants = RelatedJoin('Plant', intermediateTable='userPlant',
joinColumn='userId', otherColumn='plantId')
userLinks = MultipleJoin('UserLink', joinColumn='userId')
class Qucm(SQLObject):
class sqlmeta:
style = Style(longID=True)
idName = 'qucmId'
name = UnicodeCol(length=50)
plant = ForeignKey('Plant', dbName='plantId')
ipAddress = UnicodeCol(length=20)
I'm so confused, I'm not really sure how to start. I've looked at the
SubQueries doc, but seems to me that I'll need more than that for this
case. Can someone point me in the right direction?
-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