title: Excel VBA mysql query with string variable
body: <p>So i'm doing this simple sql select from mysql database in my VBA code:</p>
  
  <pre><code>cmd.CommandText = "SELECT sum(operation_employee_execution_time) FROM employee_operation where employee_last_name like '" &amp; sEmployee &amp; "'"
  </code></pre>
  
  <p>and it is not working. If I do <code>msgbox(cmd.CommandText)</code> I see properly formatted SQL query:</p>
  
  <p><a href="https://i.stack.imgur.com/VWriU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VWriU.png" alt="enter image description here"></a></p>
  
  <p>Unfortunately result of that query is nothing (meaning like clause could not find a match), but if I hardcode the value of the variable like this: </p>
  
  <pre><code>cmd.CommandText = "SELECT sum(operation_employee_execution_time) FROM employee_operation where employee_last_name like 'Levkovic'"
  </code></pre>
  
  <p>It works perfectly... </p>
  
  <p>Anyone could give me some advice here? I thought that this will be some sort of encoding problem but adding <code>"CharacterSet=utf8;"</code> to my connection string did not help (that column in db is <code>utf8mb4_bin</code>)</p>