title: update table where column name is set as variable mysql
body: <p>I am creating a mysql statement that should update a table, but instead of setting a column name to be equal to some value the normal way, I decided to make it dynamic, for example  instead of:</p>
  
  <pre><code>UPDATE mytable SET mycolumn = 'a value';
  </code></pre>
  
  <p>I use a variable. In this case:</p>
  
  <pre><code>SET @column = 'mycolumn';
  UPDATE mytable SET @column = 'a value';
  </code></pre>
  
  <p>This returns a syntax error message when I execute the update statement. Is there a way to do this?</p>