Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What MySQL would return if we refer a user variable which is not assigned any value explicitly?
In case, when we refer a user variable which is not assigned any value explicitly, MySQL would return NULL. In other words, its value would be NULL. Following example would illustrate it −
mysql> Select @X, @Y, @Z, @S, @G; +------+-------+----------+------+------+ | @X | @Y | @Z | @S | @G | +------+-------+----------+------+------+ | Ram | Shyam | Students | 5000 | NULL | +------+-------+----------+------+------+ 1 row in set (0.00 sec)
We can see from the above result set that @X,@Y,@Z and @S has been assigned values explicitly and they returned the values but @G variable has not been assigned any value explicitly hence when we refer to it then MySQL returns NULL because it is having a NULL value.
Advertisements
