title: What's the correct form of MySQL query with scattered variables?
body: <p>I already checked the questions related to this but I can't seem to find anything that is helping me in my problem. </p>
  
  <pre><code>    # this is the code that comes before the mysql query 
      select = request.args['select']
      print select # ["c9", "TEMP"]
      c, conn = connection()
      print "connected"
  </code></pre>
  
  <p>After I implement this query, it doesn't produce any data</p>
  
  <pre><code>data = c.execute("SELECT Client, %s, Date_Time FROM data WHERE Client = %s and Date_Time &gt; '2016-04-26 18:17:15'", (select[1],select[0]))
  # prints data = 0
  </code></pre>
  
  <p>this one produces an error with my sql query </p>
  
  <pre><code>data = c.execute("SELECT Client, '%s', Date_Time FROM data WHERE Client = '%s' and Date_Time &gt; '2016-04-26 18:17:15';", (select[1],select[0]))
  # (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'\\"\'\', Date_Time FROM data WHERE Client = (\'[\') and Date_Time &gt; \'2016-04-26 18:17\' at line 1')
  </code></pre>
  
  <p>no data is produced from here as well</p>
  
  <pre><code>data = c.execute("SELECT Client, '%s', Date_Time FROM data WHERE Client = %s and Date_Time &gt; '2016-04-26 18:17:15';", (select[1],select[0]))
  # prints data = 0
  </code></pre>
  
  <p>However, just putting this command and it works (no variables) </p>
  
  <pre><code>data = c.execute("SELECT Client, TEMP, Date_Time FROM data WHERE Client = 'c9' and Date_Time &gt; '2016-04-26 18:17:15';")
  </code></pre>
  
  <p>So where's my error? :/ </p>