[KLUG Members] Setting user variables in MYSQL

Adam Williams members@kalamazoolinux.org
09 May 2002 17:54:47 -0400


>How do you set user variables in MYSQL?  
>Here is a basic example that I thought would work:
>SET @variable_name=0
>select @variable_name:=(@variable_name + 1) as var
>from table_name;

In all my years of sql I've never seen anything like this (and I've seen
some kwazy kwueries).

Assuming that the above worked, it would result in something like

select 0:=1 as var from table_name

I have no idea what that would "mean".   And do you have columns with
names like 0, 1, 2, 3.

I suspect I'm missing what you actually mean (other possibility is that
mySQL allows some funky stuff).