Problem:
I need to translate some errors into a select statement.
Example:
I have a table with the following information:
-----------------------
|ID | NAME | ERROR|
|-----------------------|
| 001 | example1 | err1 |
| 002 | example2 | err2 |
| 003 | example3 | err3 |
-----------------------
Every mistake means:
err1: Login failed
err2: Failure of the database
err3: Hard drive full
I need to make a select statement that returns the information as follows:
-----------------------------------------
|ID | NAME | ERROR |
|-----------------------------------------|
| 001 | example1 | Login failed |
| 002 | example2 | Failure of the database|
| 003 | example3 | Hard drive full |
-----------------------------------------
My intent
: I've tried the following:
SELECT *,
CASE
WHEN error=err1 THEN 'Login failed'
WHEN error=err2 THEN 'Failure of the database'
WHEN error=err3 THEN 'Hard drive full'
END
FROM table;