CASE WHEN NULL makes wrong result in SQLite?
database, null, sql, sqlite
Solution
You can't compare with `NULL` like that, you should try:
SELECT CASE WHEN myImageColumn IS NULL THEN 0 ELSE 1 END
FROM myTable
Problem
I have a table with a column of image type, the table has some rows but all the rows haven't had any image yet, they are all null. To test the CASE WHEN NULL, I've tried this and it gave a strange result: ``` SELECT CASE myImageColumn WHEN NULL THEN 0 ELSE 1 END FROM myTable ``` All the returned rows were in a column of 1's (I thought 0's). What is wrong here? Your help would be highly appreciated! Thank you!