I found very strange MySQL behavior:
I have a string with umlaut letters, and I run some IF expression on it. Something like:
IF(length(field) < 10, '', replace(field, "\n", "<BR>"))
It it works fine.
However, if I replace this if by CASE, then the result is cut on the first unlaut letter!
CASE WHEN length(field)<10 THEN '' ELSE replace(field, "\n", "<BR>") END
Also, I noticed that it happens only when there is also GROUP BY part in the query.
I can't understand what's the difference between CASE and IF - from logical point of view both should return the same result exactly.
Anyone knows why the is difference between these two commands?
"IF is a single fork, "CASE" can be multiple Use "Case" if you have more than two values optional values, "IF" when you have only two values.
General structure of CASE is:
CASE x
WHEN a THEN ..
WHEN b THEN ..
...
ELSE
END
General structure of IF:
IF (expr)
THEN...
ELSE...
END
So, basically IF is a CASE with only one 'WHEN' statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With