You get a bonus - 1 coin for daily activity. Now you have 1 coin

MySQL: the syntax of the CASE WHEN THEN ELSE query

Practice



Of course, there's information on the internet about the format for writing a CASE query in MySQL, but no matter how much I looked, the information turned out to be wrong.

Here's the correct format:

CASE tablefield WHEN opt1 THEN result1 WHEN opt2 THEN result2 ELSE result3 END

For example, most sites write "END CASE" at the end instead of a simple "END", which, of course, is wrong (I won't give examples of the sites - I don't want to point fingers - these are very respected sites, and I'm sure this mistake, while unfortunate, is a case of "accidentally copying an error from one another"). Applies to: MySQL 5.x

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)