From: Mark M. <ma...@di...> - 2003-07-07 20:51:20
|
Hi all, I am super-excited about this package, but I can't seem to figure out how do execute a simple LEFT JOIN SQL query. Am I missing somehting basic here? I have my two tables set up, but I can't issue the SQL directly with the .select() method because it throws that pesky WHERE in at the end. Here is what I am getting: class Customer(SQLObject): _table = "customer" _idName = "custid" Company = StringCol(length=30, dbName='company', default="") Street = StringCol(length=35, dbName='street', default="") City = StringCol(length=20, dbName='city', default="") Province = StringCol(length=15, dbName='province', default="") PostalCode = StringCol(length=7, dbName='pcode', default="") Contacts = MultipleJoin('Contact', joinColumn='custid', orderBy=['LastName', '-Title', 'FirstName']) class Contact(SQLObject): _table = "contacts" _idName = "contactid" LastName = StringCol(length=15, dbName='last_name', default="") FirstName = StringCol(length=15, dbName='first_name', default="") Title = StringCol(length=25, dbName='title', default="") Customer = ForeignKey('Customer', dbName='custid', default=0) if __name__ == '__main__': all = Customer.select("""JOIN ON Contacts USING (custid)""") Gives me: Select: SELECT customer.custid, customer.province, customer.city, customer.stre et, customer.pcode, customer.company FROM customer WHERE JOIN ON Contacts USING (custid) Can anyone point me in the right direction? I need the LEFT JOIN behaviour here, not a simple equi-join, as there may be Customers defined, but no Contacts. -- Thanks a lot, Mark. |