
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- How MySQL SUM() function evaluates if the column having NULL values too?
- How MySQL evaluates if we export the data to CSV file from a table which contains a NULL value(s)?
- How MySQL SUM() function evaluates if it got the column, having character data type, as its argument?
- How can we create a MySQL stored function that uses the dynamic data from a table?
- How can we handle NULL values stored in a MySQL table by using PHP script?
- What MySQL COUNT() function returns if there are some NULL values stored in a column also?
- How to write a MySQL stored function that updates the values in a table?
- Set value only for NULL values in a MySQL table
- How to write a MySQL stored function that inserts values in a table?
- MySQL query to replace only the NULL values from the table?
- How can I customize value, instead of NULL, of a row by using MySQL IF() function?
- How MySQL evaluates if we use EXISTS operator with the subquery that returns NULL?
- How to delete the duplicate values stored in reverse order from MySQL table?
- How can I create a stored procedure to delete values from a MySQL table?
- How can I create a MySQL stored procedure that returns multiple values from a MySQL table?

Advertisements