I have a column: account_type which contains four characters. d, h, v, a. Now, if the account_type is d then it should display DBA, if a then application, if v then vendor, and if h then human. I tried this query.
SELECT da.account_name, da.account_id,da.manager_lastname, da.manager_firstname,
dap.live_password_change, dap.dev_password_change, das.status_desc,
REPLACE(RTRIM(CONCAT(IF(da.account_type = 'd', 'DBAs', 'NO'))), ' ', ', ')
FROM dba_account da
LEFT JOIN dba_account_password dap ON da.account_id = dap.account_id
LEFT JOIN dba_account_status das ON da.status = das.status_id
WHERE CAST(da.account_name AS BINARY) RLIKE '[a-z]'
AND da.account_name NOT RLIKE '[#$\\\\////]'
ORDER BY da.account_name
But i dont know how to compare 4 conditions. Any suggestions please?
You would use
CASEsimilar to this: