On Wed, May 26, 2010 at 2:42 AM, Dennis Lee Bieber <wlfr...@ix.netcom.com>wrote:
> I was, for that example, assuming that the user input "values" was > being used in a select query and hence wrapped it with wildcard markers > so that the phrase would match anywhere in the data field. > In said thread you wrote the following: clauses = [] for nm in nameList: clauses.append(nm + " like %s") where = " and ".join(clauses) #could be " or " valueList = ["%%s%" % vl for vl in valueList] SQL = "select * from table where " + where cur.execute(SQL, valueList) Ok, so let's assume we have a name list of: ["name1", "name2", "name3"] and a value list of: ["value1", "value2", "value3"] Therefore: clauses = ["name1 like %s", "name2 like %s", "name3 like %s"] where = "name1 like %s and name2 like %s and name3 like %s" SQL = "select * from table where name1 like %s and name2 like %s and name3 like %s" valueList = ("%value1", "%value2", "%value3") cur.execute("select * from table where name1 like %s and name2 like %s and name3 like %s", ("%value1", "%value2", "%value3")) Why do the values have that extra "%"? TIA, beno
-- http://mail.python.org/mailman/listinfo/python-list