Friday, June 26, 2015

MySQL NULL column during comparison




In MySQL table, I have column WorkPermit, 5 values, 'N', 'N', 'N', NULL, NULL

When we do MySQl statement  WorkPermit !=N, we expect to get 2, but result return nothing
as NULL not participate comparision in not equal.

So when we use != (not equal) in MySQL, we should add condition
( WorkPermit !=N or WorkPermit IS NULL)

No comments:

Post a Comment