title: Running a function inside SQL query with selected item as it's parameter
body: <p>I'm doing a MySQL query in an aws-lambda function.</p>
  
  <p>I'd like to know if it's possible to have a js function inside an SQL query where it would use a selected item as it's parameter. like this</p>
  
  <pre><code>Left join users user
  WHERE ( student.id = user.id AND student.age = '${Process_minimum_Age('user.dateOfBirth')}')
  </code></pre>
  
  <p>or a more realistic example</p>
  
  <pre><code>WHERE ( currentLocation = user.location AND currentTime = '${ moment().tz('user.timezone')}' )
  </code></pre>
  
  <p>I'm not sure how to refer back to SQL inside the parameter, when I try it  I get the following error.</p>
  
  <pre><code>"errorMessage": "ER_CANT_AGGREGATE_2COLLATIONS: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '='"
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>Thanks to @H. Figueiredo who kindly and promptly helped me to figure what the problem and gave me the right answer. 
  Since I was using template literals and the fact that user.timezone parameter was returning a string I had to wrap it with the following escape quote method ..  <code>'${moment().tz(</code>`\'us.timezone\'`)<br>
  (it's a bit of a challenge escaping backticks here too :)</p>