Hi guys could you please help me out here.
SELECT e.name, IF e.active = 0 THEN e.active = true WHERE e.id = #{estate_id} ELSE e.active = false WHERE e.id = #{estate_id} END IF AS Estate_status FROM estates e
Hi guys could you please help me out here.
SELECT e.name, IF e.active = 0 THEN e.active = true WHERE e.id = #{estate_id} ELSE e.active = false WHERE e.id = #{estate_id} END IF AS Estate_status FROM estates e
This is db2 syntax as you have not mentioned which DB you are using:
select e.name,
case when e.active = 0 then 'TRUE'
else 'FALSE'
end AS Estate_status,
from estates e
where e.id = #{estate_id}
I'm confused by the rest of your SQL statement. What exactly are you trying to achieve.
However, in regard to the question itself, you can't use an IF statement within the SQL like that. You can however use a CASE statment, such as:
CASE
WHEN e.active = 0 THEN 'true'
ELSE 'false'
END