简体   繁体   中英

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 guess 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"];
if($values["main_section"] == 'Bank Guarantee PBG'){    
    $strSQLInsert2 = "UPDATE commercial_acc_cust SET pbg_curr = 'pbg_curr' 
    WHERE tender_id=" . $values["tender_id"];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM