Now I know you can't directly compare NULL to anything (as null is unknown) so how would I achieve the following:
select *
from Material as m
where MtrlCode = 826 and
Exposlimit <> 'compareMe'
Where Exposlimit MAY be NULL or it may not be. 'compareMe' may also be NULL.
Therefore how do I compare the two? Both sides could be either text or NULL.
select *
from Material as m
where MtrlCode = 826
and (Exposlimit <> 'compareMe'
or (Exposlimit is null and compareme is not null)
or (Exposlimi is not null and compareme is null))
Use IFNULL function for such cases.
i.e.
WHERE IFNULL(FieldA, 'MagicConstant') = IFNULL(FieldB, 'MagicConstant')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With