I wanted to skip blank data in MySQL.
My sample query is:
SELECT id, name, date from sample where name IS NOT NULL;
Sample table:
id name date
1 24-04-2012
2 abc 23-04-2012
Now if I fire above query, it gives me both record but I want to skip data which is stored as blank i.e. There is nothing(not even NULL)?
So how can I skip 1st record? What should be my query?
So how to skip blank data in MySQL?
Please guide me.
You can ignore null fields at the class level by using @JsonInclude(Include. NON_NULL) to only include non-null fields, thus excluding any attribute whose value is null. You can also use the same annotation at the field level to instruct Jackson to ignore that field while converting Java object to json if it's null.
The symbol <> in MySQL is same as not equal to operator (!=). Both gives the result in boolean or tinyint(1). If the condition becomes true, then the result will be 1 otherwise 0. Case 1 − Using !=
Select non-empty column values using NOT IS NULL and TRIM() function. The syntax is as follows. SELECT * FROM yourTableName WHERE yourColumnName IS NOT NULL AND TRIM(yourColumnName) <> ' '; You can select non-empty value as well as whitespace from column using the same TRIM() function.
You can eliminate both NULL
and empty/blank strings from your results using the following:
where name IS NOT NULL AND name <> ''
^^^^^^^^^^^^^^ add this
Demo: http://www.sqlfiddle.com/#!2/1155a/6
Edit: As pointed out in the comments, trim
is not even necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With