Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to check if any value is Null in a MySQL table single row?
For this, you can use ISNULL in MySQL.
Let us create a table −
Example
mysql> create table demo86 -> ( -> value1 varchar(20) -> , -> value2 varchar(20) -> ); Query OK, 0 rows affected (2.77
Insert some records into the table with the help of insert command −
Example
mysql> insert into demo86 values(null,null);
Query OK, 1 row affected (0.34
mysql> insert into demo86 values(null,'John');
Query OK, 1 row affected (0.16
mysql> insert into demo86 values('David','Mike');
Query OK, 1 row affected (0.17
mysql> insert into demo86 values('Sam',null);
Query OK, 1 row affected (0.15
Display records from the table using select statement −
Example
mysql> select *from demo86;
This will produce the following output −
Output
+--------+--------+ <p>| value1 | value2 |</p>+--------+--------+ <p>| NULL | NULL |</p>| NULL | John | <p>| David | Mike |</p>| Sam | NULL | <p>+--------+--------+</p>4 rows in set (0.00 sec)
Following is the query to check if any value is Null in a single row −
Example
mysql> select *from demo86 -> where value1 is null or value2 is null;
This will produce the following output −
Output
+--------+--------+ <p>| value1 | value2 |</p>+--------+--------+ <p>| NULL | NULL |</p>| NULL | John | <p>| Sam | NULL |</p>+--------+--------+ <p>3 rows in set (0.00 sec)</p>
Advertisements
