
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
+--------+--------+| value1 | value2 |
+--------+--------+| NULL | NULL |
| NULL | John || David | Mike |
| Sam | NULL |+--------+--------+
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
+--------+--------+| value1 | value2 |
+--------+--------+| NULL | NULL |
| NULL | John || Sam | NULL |
+--------+--------+3 rows in set (0.00 sec)
Advertisements