How to skip empty data in MySQL?

I wanted to skip empty data in MySQL.

My example:

SELECT id, name, date from sample where name IS NOT NULL;

Example table:

id     name         date
1                  24-04-2012
2      abc         23-04-2012

Now, if I run on a query, it gives me both records, but I want to skip data that is stored as empty, i.e. no ( not even NULL )?

So, how can I skip the 1st entry? What should be my request?

So how to skip empty data in MySQL?

I beg you, please.

+5
source share
3 answers

You can remove both NULLempty and empty rows from the results using the following:

 where name IS NOT NULL AND name <> ''
                        ^^^^^^^^^^^^^^ add this

Demo: http://www.sqlfiddle.com/#!2/1155a/6

Change . As stated in the comments, trimnot even required.

+15
source

mellamokb, , " , sql" NULLIF mySQL:

where  nullif( trim(name) , '') is NULL
+1
SELECT id, name, date from sample where trim(name)
0
source

All Articles