- Original Poster
- #1
OK,
banging my head abit with this one. Trying to store the value from a table into a variable and failing. So if I have a table T10Company with 1 row which has the value
MYCO0001
and is the following query:
I get the return value of 1, as I would expect.
If I now want to store the result of that query in a variable like so:
@MaxNo is always NULL, I cannot understand it!
Help anyone?
Cheers
Gary
banging my head abit with this one. Trying to store the value from a table into a variable and failing. So if I have a table T10Company with 1 row which has the value
MYCO0001
and is the following query:
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;
I get the return value of 1, as I would expect.
If I now want to store the result of that query in a variable like so:
Code:
SELECT
MAX(CONVERT(RIGHT(CompanyID, 4), UNSIGNED INTEGER)) INTO @MaxNo
FROM
T10company
WHERE
LEFT(CompanyID, 4) = 'MYCO'
GROUP BY
LEFT(CompanyID, 4)
ORDER BY
RIGHT(CompanyID, 4) limit 1;
@MaxNo is always NULL, I cannot understand it!
Help anyone?
Cheers
Gary
