mjoy
mjoy

Reputation: 680

MYSQL How to check if table has NULL, not 0

I am trying to write a query to select the rows from my table that have NULL value. However, it keeps selecting the rows that have 0 in them as well. I can't figure out what to do to get it so it only looks for the word 'NULL'.

SELECT *
FROM adult4
WHERE '?' IN (workclass, education, maritalstatus, occupation, relationship,
  race, sex, nativecountry) OR NULL IN (age, fnlwgt, educationnum, 
  capitalgain, capitalloss, hoursperweek);  

Upvotes: 0

Views: 594

Answers (1)

Jens
Jens

Reputation: 69440

To check if a value is null you can use tthe isNull() function:

SELECT *
FROM adult4
WHERE isNull(age) or isNull(fnlwgt) ...

For more Information see https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html

Upvotes: 1

Related Questions