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)])
[email protected] schrieb am 25.06.2009 15:19:50:
>
> On Jun 25, 1:51 pm, Robert Marklund <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---