query=...somequery...
for n in g: query=query|db.contacts.membership.like('%'+n+'%')
rows=db(query).select(db.contacts.number)On Jun 18, 12:09 am, Nik Go <[email protected]> wrote: > I was trying to do the following: > for n in g[:]: > query += ' | ' if bool(query) else '' > query += "(db.contacts.membership.like('%" + n + "%'))" > rows=db(query).select(db.contacts.number) > > but couldn't get it to work so I resorted to executing the query using > SQLexecute instead: > > for n in g[:]: > query += ' OR ' if bool(query) else '' > query += "membership LIKE \"%" + n + "%\"" > rows=db.executesql('SELECT number FROM contacts where '+ query +';') > > Is this the web2py "way"? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

