Wednesday, June 27, 2018

sql - How do I check if a column is empty or null in MySQL?




I have a column in a table which might contain null or empty values. How do I check if a column is empty or null in the rows present in a table?



(e.g. null or '' or '  ' or '      ' and ...)

Answer



This will select all rows where some_col is NULL or '' (empty string)



SELECT * FROM table WHERE some_col IS NULL OR some_col = '';

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...