- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
- Related Articles
- What is the default type of a bit value assigned to user variables?
- How can a user explicitly end current MySQL transaction?
- How can we store a value in user-defined variable?
- What happens if I will assign a value to a MySQL user variable using a statement that returns multiple rows?
- Return value from a row if it is NOT NULL, else return the other row value in another column with MySQL
- MySQL CREATE USER with a variable?
- How can we assign a bit value as a number to a user variable?
- How Can we permanently define user-defined variable for a client in MySQL?
- Updating a MySQL table row column by appending a value from user defined variable?
- MySQL create user if it does not exist?
- Select into a user-defined variable with MySQL
- Write a single MySQL query to return the ID from the corresponding row which is a NOT NULL value
- How can we use SET statement to assign a SELECT result to a MySQL user variable?
- What if we are not sure of the type of value that we want to store in a variable. How to handle this in C#?
- What would happen if we run SELECT WHERE columnName = zero in MySQL?

Advertisements