User variables are written as @var_name. : User Defined Variables : Select Query MySQL TUTORIALS


MySQL TUTORIALS » Select Query » User Defined Variables »

 

User variables are written as @var_name.


The variable name var_name may consist of alphanumeric characters from the current character set, '.','_', and $.

One way to set a user-defined variable is by issuing a SET statement:

SET @var_name = expr [, @var_name = expr...
mysql>
mysql> SET @t1=0, @t2=1, @t3=2;
Query OK, rows affected (0.00 sec)

mysql>
mysql> select @t1;
+------+
| @t1  |
+------+
0    |
+------+
row in set (0.00 sec)

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

mysql> select @t3;
+------+
| @t3  |
+------+
2    |
+------+
row in set (0.00 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Select Query
» User Defined Variables