I am using mysql function if
.
When I run SELECT IF(NULL, 2, 3)
, I got 3
.
can I get NULL when first argument is NULL by changing this SQL?
CodePudding user response:
Use IF()
combined with ISNULL()
:
SELECT IF(ISNULL(NULL), 2, 3) -- output is 2