I have a form where the customer can type one keyword on each of the
five fields (the first field may not be empty).  From these keywords I
have to build a query that would use .like('%' keyword'%') search in
at least two fields in the database.

I am trying something like this:

        k1 = request.vars.k1
        k2 = request.vars.k2
        k3 = request.vars.k3
        k4 = request.vars.k4
        k5 = request.vars.k5
        s = '%' + k1 + '%'
        query = (db.sarua.title.like(s)|db.sarua.keywords.like(s))

The only way to do the rest looks to me something like this:

if k2:
   ... building a longer query
if k3:
   ...  add to k2-query

Is there a better way?  Maybe building a query to test a list of
strings separately against the different fields.

Johann

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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.

Reply via email to