- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I select data that does not have a null record in MySQL?
To select not-null records, use IS NOT NULL property. Let us first create a table −
mysql> create table DemoTable1792 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1792 values('John Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1792 values(NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1792 values('David Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1792 values(NULL); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1792;
This will produce the following output −
+--------------+ | Name | +--------------+ | John Smith | | NULL | | David Miller | | NULL | +--------------+ 4 rows in set (0.00 sec)
Following is the query to select data that does not have a null record −
mysql> select * from DemoTable1792 where Name IS NOT NULL;
This will produce the following output −
+--------------+ | Name | +--------------+ | John Smith | | David Miller | +--------------+ 2 rows in set (0.00 sec)
- Related Articles
- How do I exclude a specific record in MySQL?
- How do I insert a NULL value in MySQL?
- How to select from MySQL table A that does not exist in table B?
- Return records that do not have a value in a certain field with two SELECT statement in a single MySQL query
- How do I update NULL values in a field in MySQL?
- Change a MySQL column to have NOT NULL constraint
- SELECT not null column from two columns in MySQL?
- MySQL Select Rows where two columns do not have the same value?
- How do I modify a MySQL column to allow NULL?
- How do I verify that an element does not exist in Selenium 2?
- MySQL SELECT from table A that does not exist in table B using JOINS?
- What does select @@identity do in MySQL?
- How to find rows in an R data frame that do not have missing values?
- MySQL select query to fetch data with null value?
- How do I check if a column is empty or null in MySQL?

Advertisements