Reputation: 21
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
Reputation: 60493
because null values must be treated apart
where tread <> 'D' or tread is 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
Reputation: 13455
There is one more way of doing this
where not ifnull(tread, '-1') ='D'
Upvotes: 0