From: rich gray Date: October 4 2012 2:01pm Subject: Re: (real) silly question about variables... List-Archive: http://lists.mysql.com/mysql/228317 Message-Id: <506D96C6.6080306@richgray.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 04/10/2012 15:52, MAS! wrote: > Hi > > I know there'd be a reason, but I can't understand that.. > > mysql> select @valore:=rand(), @valore, @valore:="ciao", @valore; > +-------------------+-------------------+-----------------+---------+ > | @valore:=rand() | @valore | @valore:="ciao" | @valore | > +-------------------+-------------------+-----------------+---------+ > | 0.483624490428366 | 0.483624490428366 | ciao | 0 | > +-------------------+-------------------+-----------------+---------+ > 1 row in set (0.00 sec) > > mysql> select @valore:=rand(), @valore, @valore:="ciao", @valore; > +-------------------+-------------------+-----------------+---------+ > | @valore:=rand() | @valore | @valore:="ciao" | @valore | > +-------------------+-------------------+-----------------+---------+ > | 0.747058809499311 | 0.747058809499311 | ciao | ciao | > +-------------------+-------------------+-----------------+---------+ > 1 row in set (0.00 sec) > > why in the first execution the latest value is 0 and not 'ciao'? > and why in the first 2 columns the variables seems works as expected!? what version of MySQL are you running? I get this:- Server version: 5.5.17-log MySQL Community Server (GPL) mysql> select @valore:=rand(), @valore, @valore:="ciao", @valore; +--------------------+--------------------+-----------------+---------+ | @valore:=rand() | @valore | @valore:="ciao" | @valore | +--------------------+--------------------+-----------------+---------+ | 0.8187706152151997 | 0.8187706152151997 | ciao | ciao | +--------------------+--------------------+-----------------+---------+ Rich