What is a SQL case statement? Well, it's much like a switch statement in a development language. It allows you to test several different cases for a field and determine what you would like to do for each one.

If you have ever visited Mysql's documentation, you may have been as lost as I was. You will find something like this:

CASE v

WHEN 2 THEN SELECT v;

WHEN 3 THEN SELECT 0;

ELSE

BEGIN

END;

END CASE;



If you are as confused as I was, let me provide you a better, more clear example.