SELECT IFNULL(Col,'b') FROM Table
Checks Col and returns Col if is not null if not it returns b.
How do I check Col, and return ‘a’ if not null or ‘b’ if null.
I tried this:
SELECT IF(Col=NULL,'a','b') FROM Table
Which always returns ‘b’. How is this done?
Use
IS NULLto check whether a column is null, instead of= NULL.Every value compares with
NULLthe result will beNULL, so you will always getb.