Reputation: 736
I'm preety new to SQLite. I have a preety basic question.. Why can't I select rows where specific column equals zero?
The is_unwanted column is type TINYINT
(which I see in SQLite basically means INTEGER
)
So, I have only one record in the database (for testing). When I try
SELECT is_unwanted FROM 'urls'
I get a result of "0" (zero), which is fine because that column contains the actual number 0.
I tried =>
SELECT * FROM 'urls' WHERE is_unwanted = 0
And got NO result, but
SELECT * FROM 'urls' WHERE is_unwanted <> 0
gives me result.
What am I doing wrong??
Upvotes: 0
Views: 1973
Reputation: 2333
You could try:
SELECT * FROM urls WHERE coalesce(is_unwanted,'') = ''
Upvotes: 0
Reputation: 41170
Try running
select '{' || is_unwanted || '}' from urls
to see if the value in the database is really a string containing spaces.
SQLite is a dynamically typed database; when you specify TINYINT
is is a hint (SQLite uses the term "affinity") for the column. You can use
select is_unwanted, typeof(is_unwanted) from urls
to see the values with their types.
Upvotes: 2