Home > Database > Mysql Tutorial > 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?

王林
Release: 2023-08-30 17:37:09
forward
572 people have browsed it

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template