SET user variable in mysql returns null?

When I created a custom variable using

SET @a =10; 

also i checked

SET @a := 10;

The above request completed successfully. when accessing a variable, it gives me a NULLvalue instead 10. I accessed specific variables with this query

SELECT @a;
+5
source share
1 answer

The only way this can happen (in a client session) - and how it happens to me from time to time - you get a bit through a short timeout on the client connection. This happens as follows:

mysql> set @a = 10;

mysql> [wait for N+1 minutes, where N is the client timeout]

mysql> select @a;
+------+
| NULL |
+------+
| NULL | 
+------+
1 row in set (0.00 sec)

You must initialize your variables and use them in a continuous client session. When the session leaves, you lose all your variables.

, , , ; , "SET..." "SELECT..." . .

+1

All Articles