I do not think this can be done in query (not a web2py issue but a SQL
issue).

You need to do

s1=db(q1).select(db.details.lokid)
s2=db(q2).select(db.keywords.lokid)
s = list(set([row.lokid for row in s1]).union(set([row.lokid for row
in s2])))

Perhaps somebody else has a better suggestion.

On Aug 17, 9:52 am, max <dulip.withan...@gmail.com> wrote:
> sorry for the failure  in copy and pasting as i have a lot more fields
> and i just kept it simple.
>
> First Table:
> my_db.define_table('details',
> SQLField('lokid'),
> SQLField(''titel'),
> )
>
> Second table:
> my_db.define_table('keywords',
> SQLField('lokid',my_db.lokid)),
> SQLField('keyword')
> )
>
> my search form looks
> form2 = FORM(INPUT(_type="text", _name='my_search'), INPUT
> (_type='submit', _value="mySearch"))
>
> my queries are like:
>
>  q1 = (my_db.details.titel.lower().like('%%%s%%' % my_search))
>  q2 = (my_db.keywords.keyword.like('%%%s%%' % my_search))
>
> ______________________
>
> On 17 Aug., 16:10, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Sorry, I still think your tables have something missing since q1 and
> > q2 reference fields that do not exist.
>
> > On Aug 17, 8:47 am, max <dulip.withan...@gmail.com> wrote:
>
> > > Sorry, made a failure in my posting. I corrected it now.
>
> > > First Table:
> > > my_db.define_table('details',
> > > SQLField('lokid'),
> > > SQLField(''details'),
> > > )
>
> > > Second table:
> > > my_db.define_table('keywords',
> > > SQLField('lokid',my_db.lokid))
> > > SQLField('lokid',my_db.keyword))
>
> > > my search form looks
> > > form2 = FORM(INPUT(_type="text", _name='my_search'), INPUT
> > > (_type='submit', _value="mySearch"))
>
> > > my queries are like:
>
> > >  q1 = (my_db.details.titel.lower().like('%%%s%%' % my_search))
> > >  q2 = (my_db.keywords.details.like('%%%s%%' % my_search))
>
> > > I have to search for keyword in  table 'keywords' and get the lokid
> > > for table 'details' and show the values. At the same time i have to
> > > search the 'detai'ls table and show it's own values for the same
> > > query.
> > > Optimally i put both the results in a dictionary and sort and it and
> > > put in my view. My problem is how can i combine the search.
>
> > > On 17 Aug., 15:26, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > I do not understand. Moreover in
>
> > > >  q1 = (my_db.details.titel.lower().like('%%%s%%' % my_search))
> > > >  q1 = (my_db.keywords.schlagwortzo.like('%%%s%%' % my_search))
>
> > > > table details does not have a titel (nor title) field and table
> > > > keywords does not have a schlagwortzo field.
>
> > > > Something is missing.
>
> > > > On Aug 17, 8:19 am, max <dulip.withan...@gmail.com> wrote:
>
> > > > > I am having a small problem, that i can't solve  using the example in
> > > > > book.
>
> > > > > I want to  search in two tables for one search word and output only
> > > > > rows in one table. I can't write the joined statement using web2py DAL
> > > > > commands.
>
> > > > > First Table:
> > > > > my_db.define_table('details',
> > > > > SQLField('lokid'),
> > > > > SQLField(''details'),
> > > > > )
>
> > > > > Second table:
> > > > > my_db.define_table('keywords',
> > > > > SQLField('lokid',my_db.details))
>
> > > > > my search form looks
> > > > > form2 = FORM(INPUT(_type="text", _name='my_search'), INPUT
> > > > > (_type='submit', _value="mySearch"))
>
> > > > > my queries are like:
>
> > > > >  q1 = (my_db.details.titel.lower().like('%%%s%%' % my_search))
> > > > >  q1 = (my_db.keywords.schlagwortzo.like('%%%s%%' % my_search))
>
> > > > > I have to combine these commands.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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