'Empty column does not return NULL or empty
I imported a CSV file using LOAD DATA INFILE and have this column called Context.
The entire column appears empty - which it shouldn't be, because I already set the DEFAULT to be NULL. So I expected NULL to appear in the entire column.
I have tried if it is empty or NULL but the code below returns 0
SELECT COUNT(*) FROM table
WHERE Context IS NULL OR Context = '';
So now I do not know where the problem is.
FYI: This column is in TEXT datatype and I could change it to VARCHAR, but NOT INT - I don't know if it's related to the problem.
Solution 1:[1]
Based on this thread, I modified my query to the following and was able to solve the problem.
UPDATE table SET Context = NULLIF(Context,' ');
UPDATE table SET Context = NULLIF(Context, '\t');
UPDATE table SET Context = NULLIF(Context, '\n');
UPDATE table SET Context = NULLIF(Context, '\r');
So the original problem could be caused by either \t , \n or \r.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Truc Tran |
