In my MySQL table, I have some rows with status = NULL and some with status = 0
When selecting them in a query:
SELECT *
FROM `table`
WHERE `status` != 0
This ignores both 0 and NULL values.
How can I ignore ONLY 0 values?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
is nullpredicate:if
statusis a numeric field:if
statusis a text field:This works because
NULL != 0evaluates asNULLandNULL OR TRUEevaluates asTRUE. Rows whose inclusion condition evaluates toNULLare rejected.