MySQL NULLIF() Function

NULLIF compares two expression provided within it and returns null if it is equal otherwise the first expression is returned.


NULLIF(exp1, exp2)


We will be playing around with the emp table here.

mysql if null

We will try to make null those who has office code 772.

select * , nullif (officeCode, 772) as Fired from emp;

mysql null if

So this is how we can play around with NULLIF function.

Fri, 07/01/2022 - 13:33
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.