Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How MySQL stored function evaluates if it got NULL value while using the dynamic values from a table?
In such kind of cases when a stored function got NULL values then it will return NULL as the result. It can be understood from the example below in which we have a NULL value in the records of student ‘Mohit’. Now, when we will apply the stored function ‘avg_marks’ on this data, it will return NULL as result.
mysql> Select * from Student_marks;
+-------+------+---------+---------+---------+
| Name | Math | English | Science | History |
+-------+------+---------+---------+---------+
| Raman | 95 | 89 | 85 | 81 |
| Rahul | 90 | 87 | 86 | 81 |
| Mohit | 90 | NULL | 86 | 81 |
+-------+------+---------+---------+---------+
3 rows in set (0.00 sec)
mysql> SELECT Avg_marks('Mohit') AS 'MOHIT_marks';
+-------------+
| MOHIT_marks |
+-------------+
| NULL |
+-------------+
1 row in set (0.00 sec)Advertisements