lovespring
lovespring

Reputation: 19559

How to select this in mysql?

the field value equal to zero OR it is NULL ?

Upvotes: 1

Views: 107

Answers (3)

VoodooChild
VoodooChild

Reputation: 9784

There is handy function called ISNULL which allows you to return a different value if it is. You can use it like:

SELECT ISNULL(fieldName, -999)
FROM _table

Also, for your main question:

SELECT * FROM _table
  WHERE field IS NULL OR field = 0

Upvotes: 1

jweber
jweber

Reputation: 589

SELECT * FROM [tablename] WHERE [fieldname] = 0 OR [fieldname] IS NULL

Upvotes: 7

Scott DePouw
Scott DePouw

Reputation: 3899

SELECT * FROM table
WHERE field = 0 OR field IS NULL

Upvotes: 5

Related Questions