I have a query that looks like this:
SELECT id, description, default_error, custom_error FROM `table1`;
Which gives me
(int) (Text) (Varchar) (Varchar)
id Description Default_Error custom_error
---------------------------------------------------
1 Hello Error 123
2 World Error 456 This is a custom Error
I’d like to select an extra column (“error”) that has the value of default_error if custom_error is EMPTY, and the value of custom_error if custom_error is NOT EMPTY.
Any idea how to do this in MySQL?
Try
OR – if custom_error is
NULLby default