Select*fromStudent_marks;+-------+------+---------+---------+-------- -+|Name |Math|English|Science|History|+-------+------"/> Select*fromStudent_marks;+-------+------+---------+---------+-------- -+|Name |Math|English|Science|History|+-------+------">

Home  >  Article  >  Database  >  How does a MySQL stored function evaluate whether it gets a NULL value when using a dynamic value from a table?

How does a MySQL stored function evaluate whether it gets a NULL value when using a dynamic value from a table?

王林
王林forward
2023-08-30 17:37:09525browse

MySQL 存储函数如何在使用表中的动态值时评估它是否获得 NULL 值?

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete