Re: user variable ist not assigned when using function like SUM(), MAX(), AVG()
Hartmut Holzgraefe <[email protected]> Tue, 07 Sep 2004 12:09:45 +0200
| Newsgroups | gmane.comp.db.mysql.bugs |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > Hello, > > this is may first bug report so I don't really know exactly what and how to > tell ... > > The bug appears in all tested versions: > 4.0.12-nt/Windows 2000 prof. SP4 > 4.0.15/Linux/SuSE > 4.0.17-nt/Windows XP prof. SP1 > 4.0.20-nt/Windows 2000 prof. SP4 > 5.0.00-alpha/Windows XP prof. SP1 > > User variables are assigned correctly with > SELECT @var := value; > > This fails when one of the the following functions is used > MIN(), MAX(), SUM(), AVG(), COUNT() ... > This is documented behaviour, see http://dev.mysql.com/doc/mysql/en/Variables.html [...] Note: In a SELECT statement, each expression is evaluated only when sent to the client. This means that in a HAVING, GROUP BY, or ORDER BY clause, you cannot refer to an expression that involves variables that are set in the SELECT list. [...] The general rule is to never assign and use the same variable in the same statement. [...] -- Hartmut Holzgraefe <[email protected]> -- MySQL Bugs Mailing List For list archives: http://lists.mysql.com/bugs To unsubscribe: http://lists.mysql.com/[email protected]