Send your app if you don't matter, I will try to write your query...

But you may be able to do it by reading the book about Left outer join :

http://www.web2py.com/book/default/chapter/06?search=left+join#Left-Outer-Join

Ex.:

rows=db().select(
        db.person.ALL, db.dog.ALL,
        left=db.dog.on(db.person.id==db.dog.owner))


~

SELECT *

FROM person

JOIN dog

ON (dog.owner = person.id)



If you have a where clause :

rows=db(WHERE CLAUSE).select(
        db.person.ALL, db.dog.ALL,
        left=db.dog.on(db.person.id==db.dog.owner))


This thread could help :

https://groups.google.com/group/web2py/browse_thread/thread/a033d703deba3712/dcbd912788cdbec4?lnk=raot&pli=1


You can also start by doing raw SQL to make it works for now :


http://www.web2py.com/book/default/chapter/06?search=left+join#Generating-raw-SQL


Richard

2011/7/28 António Ramos <[email protected]>

> hello
> i have table requests,products,clients,auth_user and comments
>
> all tables have related records except comments
>
>
> this table is related with requests and may be empty for a request
>
> how to do a left join between these 5 tables?
>
>
> i want to select  records between  requests,products,clients,auth_user and
> comments even if comments is empty for a record
>
>
> thank you
>
> Antonio
>
>

Reply via email to