MySQL SELECT INTO <variable> returns null but query returns a value
===

OK So for some reason I cannot get this query to return a value when I do a select into.

Given a table t10company, I have a column called CompanyID which is of CHAR(8), it has a value in it of:

MYCO0001

If I issue the following query:
    
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;

I get a return value of 1 which is what I would expect.

If I issue the exact same query except with INTO @myvar and then do a SELECT @myvar 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?

Thanks in anticipation


Gary
