title: MySQL function to to evaluate a string as integer based on array of data
body: <p>I have the following SQL query:</p>
  
  <pre><code>UPDATE my_records, units
  SET my_records.unit_id = units.id
  WHERE my_records.column_1 = units.column_1 AND my_records.column_2 = units.column_2
  AND my_records.id &gt; 0 AND my_records.id &lt;= 1000
  ORDER BY my_records.id
  </code></pre>
  
  <p>The problem is <code>my_records.column_1</code> is an integer and <code>units.column_1</code> is a string. But they reference the same array of data:</p>
  
  <pre><code>[ 'Medical', 'Legal', 'Auto', 'Electrical', 'Software', 'Education' ]
  </code></pre>
  
  <p>So <code>my_records.column_1</code> can be 0 and <code>units.column_1</code> can be 'Medical'. But I can discern that 'Medical' is 0 because it is the first element of the array.</p>
  
  <p>Is there a function I can pass to MySQL to convert that string of 'Medical' to the appropriate index like 0? </p>