kusum modi
kusum modi

Reputation: 21

Mysql Null value not included in result

In a mysql table I have an enum type column tread ('Y','I','N','D') default Null. When I retrieve data from table and put condition on that column like tread!='D' then the columns that have Null values are not included in result.

Upvotes: 2

Views: 71

Answers (2)

Raphaël Althaus
Raphaël Althaus

Reputation: 60493

because null values must be treated apart

where tread <> 'D' or tread is null

working with null

or you can "transform" the null values before equality test:

ANSI version (coalesce)

where COALESCE(tread, ' ') <> 'D'

mysql only (IFNULL)

where IFNULL(tread, ' ') <> 'D'

Upvotes: 3

Sashi Kant
Sashi Kant

Reputation: 13455

There is one more way of doing this

where not ifnull(tread, '-1') ='D'

Upvotes: 0

Related Questions