title: A query to find the value of a variable (MySQL) and saving it to another variable for a different query
body: <p>I am having a table with 2 columns which map my internal_id with a external_id.</p>
  <pre><code>my_Id       external_id
      32312        23412
      23234        12345
  </code></pre>
  <p>I am getting data from an API and I receive external_ids. I am trying to make a function using python to check if the external_ids I got from the api exist in my mapping table.
  If exist, the corresponding my_id should be the output from this function.
  I want to save it in a variable which will be inserted in another table together with other info I get from the API.</p>
  <pre><code>def get_my_id(external_system_id):
    query = cursor.execute(&quot;&quot;&quot;SELECT my_id FROM table
                            WHERE external_system_id=:external_system_id, external_system_id=external_system_id&quot;&quot;&quot;)
     
     print(query)
     return(query)
  </code></pre>
  <p>My query is wrong but not sure how to amend it to take a variable and to be able to work with any value received
  EDIT: I tried the solution from nbk, :</p>
  <pre><code>query = cursor.execute(&quot;&quot;&quot;SELECT my_id FROM `tablename` WHERE customer_id=%s&quot;&quot;&quot;,(customer_id,))
  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 '%s&quot;&quot;&quot;, (external_system_id)' at line 2
  </code></pre>