Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to write something like
if(?) x elseif(?) y else z
and also I want to use CASE WHEN FOR THIS.
MySql has IF(cond, true, false). You can nest them.
IF(cond, true, false)
So you can do IF(a, x, IF(b, y, z)) for if(a) x elseif(b) y else z
IF(a, x, IF(b, y, z))
if(a) x elseif(b) y else z
You can also write
CASE WHEN a THEN x WHEN b THEN y ELSE z END
to do the same thing. Pretty straightforward. Some other makes of DBMS server use IIF() instead of IF().
IIF()
IF()
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.