Maybe I'm wrong but I think Robert needs a left join. something like...

result = db(db.images.id==db.image_info.image_id).select(\
        left=[db.keyword.on(db.keyword.id==db.image_keyword.keyword_id)])

web2py@googlegroups.com schrieb am 25.06.2009 15:19:50:

> 
> On Jun 25, 1:51 pm, Robert Marklund <robbelibob...@gmail.com> wrote:
> > I would like to do a join but get results even if it was unsucessfull.
> > Like this
> > query = (db.images.id == db.image_info.image_id)  &
> > (db.images.id==db.image_keyword.image_id)
> > & \
> >               (db.keyword.id==db.image_keyword.keyword_id)
> > I want to get the resulting rows even doe no keywords exists.
> > like this row.image = the image
> > row.image_info = the image info
> > row.keyword = None if there is no keyword.
> > Is this possible ?
> 
> Surely you just do 2 queries.
> 1st do the JOIN:
> query = (db.images.id == db.image_info.image_id) &
> (db.images.id==db.image_keyword.image_id)
> 
> Then add keywords via lookups:
> sqlrows = db(query).select()
> for row in sqlrows:
>     query2 = (db.image_keyword.image_id==row.id) &
> (db.keyword.id==db.image_keyword.keyword_id)
>     row.keyword = db(query2).select()[0]
> 
> (Untested code)
> 
> F
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to