<div class="gmail_quote">On Wed, May 26, 2010 at 2:42 AM, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
 I was, for that example, assuming that the user input "values" was<br>
being used in a select query and hence wrapped it with wildcard markers<br>
so that the phrase would match anywhere in the data field.<br></blockquote><div><br>In said thread you wrote the following:<br><br>clauses = []<br>
for nm in nameList:<br>
        clauses.append(nm + " like %s")<br>
where = " and ".join(clauses)   #could be " or "<br>
valueList = ["%%s%" % vl for vl in valueList]<br>

SQL = "select * from table where " + where<br>

cur.execute(SQL, valueList)<br>
<br>Ok, so let's assume we have a name list of:<br><br>["name1", "name2", "name3"]<br><br>and a value list of:<br><br>["value1", "value2", "value3"]<br><br>
Therefore:<br><br>clauses = ["name1 like %s", "name2 like %s", "name3 like %s"]<br>where = "name1 like %s and name2 like %s and name3 like %s"<br>SQL = "select * from table where name1 like %s and name2 like %s and name3 like %s"<br>
valueList = ("%value1", "%value2", "%value3")<br>cur.execute("select * from table where name1 like %s and name2 like %s and name3 like
 %s", ("%value1", "%value2", "%value3"))<br><br>Why do the values have that extra "%"?<br>TIA,<br>beno<br></div></div><br>