Sanju Menon Sanju Menon - 1 year ago 56
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'
WHERE tender_id=" . $values["tender_id"];

Can anyone pls help me with this please..

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