title: python - MySQLdb Like operator with wildcard
body: <p>I am having problems executing a query with a wildcard in it with MySQLdb in python.</p>
  
  <p>My code </p>
  
  <pre><code>sql = "SELECT COUNT(id) FROM table WHERE name LIKE '%s%'"
  with con:
      cur.execute(sql, (name,))
  </code></pre>
  
  <p>The complicated thing about this is the % after the string %s. Based on the documentation, if there's no wildcard operator %, I could just do <code>LIKE %s</code> but I don't know how to proceed from there for my problem.</p>
  
  <p>I found this question on stack <a href="https://stackoverflow.com/questions/26536676/python-mysql-parameterized-query-conflicts-with-wildcard-in-like-statement">Python MySQL parameterized query conflicts with % wildcard in LIKE statement</a> which is similar to my question but doesn't take a dynamic argument. I tried escaping the wildcard operator like in the link above, but I still get a SQL syntax error.</p>
  
  <p>Anyone has any idea?</p>
  
  <p>Thanks</p>