Sanju Menon Sanju Menon - 5 months ago 9
SQL Question

MySql CASE Statement in an UPDATE Query

I have a problem in getting the values from Table A and updating to Table B with a CASE Statement. My CASE Statement is as follows. I gues there is an Syntax error:

$strSQLInsert2 = "UPDATE commercial_acc_cust SET pbg_curr =
CASE WHEN ('".$values["main_section"]."'='Bank Guarantee PBG') Then 'pbg_curr'
END
WHERE tender_id=" . $values["tender_id"];


Can anyone pls help me with this please..

Answer
if($values["main_section"] == 'Bank Guarantee PBG'){    
    $strSQLInsert2 = "UPDATE commercial_acc_cust SET pbg_curr = 'pbg_curr' 
    WHERE tender_id=" . $values["tender_id"];
}