MySQL Tutorial

MySQL Tutorial MySQL Features MySQL Database Introduction MySQL Environmental Setup MySQL Data Types MySQL variable MySQL Advance table Query MySQL database queries MySQL Entity-Relationship Model MySQL Table Query MySQL Operators MySQL logical conditions MySQL Queries MySQL Clauses Clustered vs Non-Clustered Index MySQL Full text index MySQL Descending Index MySQL Invisible Index MySQL Composite Index MySQL Prefix index MySQL Index MySQL Create index MySQL Drop Index MySQL Show index MySQL Unique index MySQL Table MySQL Variable MySQL View MySQL Constraints MySQL Command Line Client Basic Queries MySQL Stored Procedure MySQL IF Statement MySQL Subquery MySQL Triggers

MySQL Join

MySQL Join MySQL CROSS JOIN MySQL DELETE JOIN MySQL EQUI JOIN MySQL INNER JOIN MySQL Union MySQL NATURAL JOIN MySQL RIGHT JOIN MySQL SELF JOIN MySQL UPDATE JOIN

MySQL Function

MySQL Function MySQL AVG() Function MySQL SUM() Function MySQL String() Function MySQL Advance() Function MySQL Aggregate() Function MySQL COALESCE() Function MySQL Control Flow Function MySQL COUNT() Function MySQL Date And Time Function MySQL GREATEST() Function MySQL ISNULL() Function MySQL LEAST() Function MySQL Math() Function MySQL MAX() Function MySQL MIN() Function MySQL find_in_set() function MySQL ASIN() Function MySQL CEIL() function MySQL CEILING() function MySQL TAN() Function MySQL Truncate() Function MySQL FLOOR() function MySQL LN() function MySQL LOG2() function MySQL LOG10() function MySQL MOD() function MySQL PI() function MySQL POW() function MySQL RADIANS() function MySQL RAND() function MySQL ROUND() function MySQL Character Length Function MySQL Current Date Function MySQL Date Add Function MySQL Date Format Function MySQL Datediff Function MySQL Day Function MySQL Elt Function MySQL Export Set Function MySQL Field Function MySQL Format Function MySQL From Base64 Function MySQL Hex Function MySQL Insert Function MySQL Instr Function MySQL Length Function MySQL CONCAT() function MySQL FIND_IN_SET() function MySQL LIKE() function MySQL LOAD_FILE() function MySQL LOCATE() function MySQL LOG() function MySQL MONTHNAME() function MySQL NOW() function MySQL PERIOD_ADD() function MySQL PERIOD_DIFF() function MySQL POWER() function MySQL QUARTER() function MySQL REVERSE() function MySQL RIGHT() Function MySQL RPAD() function MySQL RTRIM() function MySQL SEC_TO_TIME() function MySQL SOUNDEX() function

Questions

Which Clause is Similar to Having Clause in MySQL

Misc

MySQL Error 1046 - No Database Selected Failed to Start MySQL Service Unit MySQL Service Unit not Found Import MySQL Connector Mudule not Found Error No Module Named MySQL Joins Available in MySQL MySQL Docs MySQL Download For Windows 7 64 Bit MySQL Error Code 1064 MySQL Export MySQL History MySQL Host MySQL Import MySQL Drop All Tables MySQL Drop MySQL Error Code 1175 MySQL Events MySQL Except MYSQL Foreign Key Constraint MySQL If Exists MySQL IndexOf MySQL List All Tables json_extract in MySQL TIMESTAMPDIFF in MySQL MySQL Syntax Checker Sudo MySQL Secure Installation

MySQL ISNULL function

This function is used to check the null value in table data. It returns the result in a Boolean form. If table data is null, then the output becomes 1. If table data is not null, then the output becomes 0.

Syntax

The ISNULL function syntax shows below.

ISNULL (value);

MySQL ISNULL function with table syntax shows below.

Select * from table_name WHERE ISNULL (column name);

Prerequisite for the comparison function

  • Create table in the MySQL system using the below statement.
mysql> CREATE TABLE `marks` (
  `roll_no` INT NOT NULL,
  `name` VARCHAR(45) NULL,
  `physics` INT NULL,
  `chemistry` INT NULL,
  `maths` INT NULL,
  `english` INT NULL,
  PRIMARY KEY (`roll_no`));
  • Insert value in the table.
  • The output command shows the table format and its information.
mysql> Select * from marks;

Use of the ISNULL function

The following are the uses of the ISNULL function:

  • The ISNULL function compares the column data between null and not null values.
  • The ISNULL function uses to find out not null values in the table columns.
  • The ISNULL function returns the Boolean value (1 or 0) of the table columns.

Example of the "ISNULL" function

Example1: Execute the following query to know the working procedure of the "null" values and their output.

mysql> SELECT ISNULL(NULL);

OUTPUT

MySQL ISNULL function

The image shows the "1" value as output. It means the ISNULL function contains a null value in the table.

Example2: The "ISNULL" function with not null column example shows below.

mysql> SELECT ISNULL(20);

OUTPUT

MySQL ISNULL function

The image shows the "0" value as output. It means the ISNULL function contains not null value in the table.

Example3: The "ISNULL" function with table data example shows below.

mysql> select ISNULL(physics) AS subject  from marks;

OUTPUT

MySQL ISNULL function

The image shows the Boolean result of the given column. The "null" value columns display one (1) value. The "not null" value columns show zero (0) value.

Example4: The "ISNULL" function with the WHERE condition example shows below.

Execute the following query to understand the "ISNULL" statement with the WHERE clause. Here the ISNULL function applies to the single column of the table.

mysql> select ISNULL(physics) AS subject from marks where no > 2;

OUTPUT

Executing the query will return the following output where we see Boolean values 0 and 1.

MySQL ISNULL function

Example5: The "ISNULL" function with table data example shows below. Here the ISNULL function applies to the multiple columns of the table.

mysql> select ISNULL(physics), ISNULL(chemistry), ISNULL(maths), ISNULL(english) from marks ORDER BY physics ASC;

OUTPUT

Executing the below output Where we see the data is displayed in ascending order.

MySQL ISNULL function

Example6: The "ISNULL" function with the "WHERE" clause example shows below. Here, the "WHERE" clause applies to the physics column. The ISNULL function applies to the single column of the table.

mysql> select * from marks where ISNULL(physics);

OUTPUT

MySQL ISNULL function

The image shows null values physics column data. Here, you can see the last two rows of the table.