00 Votes

SQLite: Check or search for empty values

Question by Guest | 2015-04-24 at 09:50

I would like to build a little SQLite query for catching all data sets containing an empty value in a specific column from my database.

How to do that in SQLite?

ReplyPositiveNegative
Avatar
-2Best Answer2 Votes

Depending on the format of your column, the value of an empty column might be NULL or an empty string.

You can filter for both using the following query (tab is your table, col the column to be searched in):

SELECT id FROM tab 
WHERE (col IS NULL) OR (col = '')

With "IS NULL" you ask whether the value of the column is NULL, with "=''" you ask whether the fetus is containing an empty string.

For example, if the column is containing a date, you should check for NULL, if the column is containing a text, you should check for an empty string, but of course, you can also just search for both.
2015-04-26 at 15:57

ReplyPositive Negative
Reply

Related Topics

SQLite: Reset AUTOINCREMENT

Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.