->select('users.id',...',
// This generates an ERROR!
'if(users.aceiteRegulamento ==1, "Sim", "Não") as aceite','users.created_at','users.updated_at')
'(CASE WHEN users.aceiteRegulamento = "0" THEN "Não" WHEN users.aceiteRegulamento = "1" THEN "Sim" ELSE "Não" END) AS aceiteRegulamento'
From https://stackoverflow.com/questions/6608102/sql-server-inline-if-else
select
case MyFlag
when 1 then 'YES'
when 0 then 'NO'
else 'OOPS'
end
from MyTable
where it's used just like a switch in C-like languages and the other is:
select
case
when MyFlag = 1 then 'YES'
when MyFlag = 0 then 'NO'
-- when some unrelated condition...
else 'OOPS'
end
from MyTable