On Wednesday, February 28, 2018 at 11:16:32 AM UTC-5, Anthony wrote:
>
> SELECT *
>> FROM
>> OnResource
>> LEFT JOIN Contact Owner ON Owner.id = OnResource.Contact
>> LEFT JOIN Contact Proxy ON Proxy.id = OnResource.Proxy
>> ORDER BY
>> Owner.LastName, Owner.FirstName
>>
>> I tried this DAL select syntax
>>
>> timesheet_owners = db().select(db.OnResource.ALL,
>> db.Contact.with_alias('Owner').ALL,
>> db.Contact.with_alias('Proxy').ALL,
>> left=[db.Contact.with_alias('Owner').on(db.Contact.id ==
>> db.OnResource.Contact),
>> db.Contact.with_alias('Proxy').on(db.Contact.id ==
>> db.OnResource.Proxy)],
>>
>
> Looks like the cross join might be a separate issue. But regarding the
> left joins, if using aliases, you will have to manually write the SQL for
> the "ON" clause rather than using DAL syntax:
>
> db.Contact.with_alias('Owner').on('Owner.id <http://db.contact.id/> =
> OnResource.Contact')
>
>
Correction, you can also do something like:
owner = db.Contact.with_alias('Owner')
owner.on(owner.id == db.OnResource.Contact)
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.