@x=0 select case when col>1 then @x:=@x+1 when col=1 then @x else @x; @x:=@x+1 end as x from t
I want to do something like what’s seen above in MySQL. The contents between the WHEN and THEN are arbitrary. However, what I want to do is seen after the ELSE statement. I know I can set a user variable where I can either output its value in the SELECT (by just using @x), or output some updated value (by using @x:=@x+1). What I want to do though is output the value @x, while also updating it @x:=@x+1. Is this possible?