title: MySQL SELECT INTO <variable> returns null but query returns a value
body: <p>For some reason I cannot get this query to return a value when I do a select into.</p>
  
  <p>Given a table <code>t10company</code>, I have a column called <code>CompanyID</code> which is of <code>CHAR(8)</code>, it has a value in it of:   <code>MYCO0001</code></p>
  
  <p>If I issue the following query: </p>
  
  <pre><code>SELECT
      MAX(CONVERT(RIGHT(CompanyID, 4), UNSIGNED INTEGER))
      FROM t10company 
      WHERE LEFT(CompanyID, 4) = 'MYCO'
      GROUP BY LEFT(CompanyID, 4) 
      ORDER BY RIGHT(CompanyID, 4) LIMIT 1;
  </code></pre>
  
  <p>I get a return value of 1 which is what I would expect.</p>
  
  <p>If I issue the exact same query except with <code>INTO @myvar</code> and then do a <code>SELECT @myvar</code> it always returns NULL. It does this in the stored proc I'm writing and also does it in a query window in MySQL Workbench. I dont know why?</p>