IF and CASE in insert query INSERT INTO TARGET_TBL (KPIName ,KPILabel)
SELECT  `d`.`si_kpi_name` AS `KPIName`, 
    IF(`t`.`kpi_val` = 0,
        WHEN (`v`.`TOIOS` &gt;= `t`.`kpi1`) THEN 'Bad'
        WHEN (`v`.`TOIOS` &gt;= `t`.`kpi2`) THEN 'Poor'
        WHEN (`v`.`TOIOS` &gt;= `t`.`kpi3`) THEN 'Fair'
        ELSE 'GOOD',

        WHEN (`v`.`TOIOS` &lt;= `t`.`kpi1`) THEN 'Bad'
        WHEN (`v`.`TOIOS` &lt;= `t`.`kpi2`) THEN 'Poor'
        WHEN (`v`.`TOIOS` &lt;= `t`.`kpi3`) THEN 'Fair'
        ELSE 'GOOD' )

        AS `KPILabel`
FROM (
    `voom_min` `v` LEFT OUTER JOIN `denver_config` `d` ON (`v`.`si_id` = `d`.`si_id`)
    LEFT OUTER JOIN gen_config g ON (d.si_name = g.si_name)
    JOIN `kpi_downstream` `t` ON ((`t`.`kpi` = 'market analysis'))
    )
WHERE (`v`.`TOIOS` IS NOT NULL)




MYSQL - Please concentrate on the part of where KPILABEL is calculated. What I am trying to do is:

If T.KPI_VALUE == O, Check set of conditions ... If not check set of conditions ...

I see in some websites the syntax of IF while using in insert query as 

if(condition, if condition yes statements, ifnot statments)


I used this syntax for if syntax ...
for "if condition yes statements I used CASE statements"

Please help me to fix the syntax.
Don't mix 

CASE value WHEN [compare_value] THEN result
          [WHEN [compare_value] THEN result ...]
          [ELSE result] END


and 

IF(expr1,expr2,expr3)


syntaxes.

See the manual