Write a query to select if column has no/empty value

The examples use the students table from our MySQL tutorial: id, name, city, marks, course_id.

-- rows with no value (NULL)
SELECT name FROM students WHERE course_id IS NULL;
Tutorials Class - Output Window
name
Vikram

NULL and an empty string are different. To find both, check both:

SELECT * FROM users
WHERE email IS NULL OR email = '';

WHERE column = NULL never returns a row, because NULL is not equal to anything. Use IS NULL and IS NOT NULL. See IN, BETWEEN and IS NULL.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.