Select*fromStudent_marks;+-------+------+---------+---------+-------- -+|Name |Math|English|Science|History|+-------+------"/> Select*fromStudent_marks;+-------+------+---------+---------+-------- -+|Name |Math|English|Science|History|+-------+------">
In this case, when the stored function gets a NULL value, it will return NULL as the result. As can be seen from the example below, the record of student ‘Mohit’ has a NULL value. Now, when we apply the stored function "avg_marks" to this data, it will return NULL as the 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)
The above is the detailed content of How does a MySQL stored function evaluate whether it gets a NULL value when using a dynamic value from a table?. For more information, please follow other related articles on the PHP Chinese website!