[web2py] Re: joins, geraldo and possible alias

2010-03-29 Thread jonatron
I tried it with sqlexecute but I would need to do quite a lot of processing on the results... Is there any work around you can think of? Is there any way to use the DAL with a select statement in the format generated from _select? Thanks, J On Mar 23, 9:35 pm, jonatron

[web2py] Re: joins, geraldo and possible alias

2010-03-23 Thread jonatron
Thanks, This is close, but it does not quite get the result I'm looking for, I basically need the following MySQL query: SELECT Calls . * , created_by.Name, handled_by.Name FROM ( Calls LEFT JOIN Users AS created_by ON Calls.CreatedBy = created_by.ID ) LEFT JOIN Users AS handled_by ON

[web2py] Re: joins, geraldo and possible alias

2010-03-23 Thread mdipierro
hmmm. it could be a bug. What do you get if you do: print db(db.Calls.id0)._select(db.Calls.ALL,db.created_by.name,db.handled_by.name, left=[created_by.on(created_by.id==db.Calls.CreatedBy), handled_by.on(handled_by.id==db.Calls.HandledBy)]) On Mar 23, 11:31 am, jonatron

[web2py] Re: joins, geraldo and possible alias

2010-03-23 Thread jonatron
I get the following: SELECT Calls.id, Calls.CallerName, Calls.CreatedBy, Calls.HandledBy, Users.Name, Users.Name FROM Users, Calls LEFT JOIN Users AS created_by ON created_by.id=Calls.CreatedBy LEFT JOIN Users AS handled_by ON handled_by.id=Calls.HandledBy WHERE Calls.id0; On Mar 23, 6:06 pm,

[web2py] Re: joins, geraldo and possible alias

2010-03-20 Thread mdipierro
created_by=db.Users.with_alias('created_by') handled_by=db.Users.with_alias('handled_by') rows = db(db.Calls.id0).select(db.Calls.ALL,db.created_by.name,db.handled_by.name, left=[created_by.on(created_by.id==db.Calls.CreatedBy), handled_by.on(handled_by.id==db.Calls.HandledBy)])