-2

I want to write something like

if(?) x elseif(?) y else z

and also I want to use CASE WHEN FOR THIS.

Kristina
  • 261
  • 2
  • 13

1 Answers1

1

MySql has IF(cond, true, false). You can nest them.

So you can do IF(a, x, IF(b, y, z)) for 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().

O. Jones
  • 103,626
  • 17
  • 118
  • 172