At two different tables, The new value of [chargeINFO.u_chargewait] I want to add and save the existing [userinfo.u_charged] value. After the query operation, I want the value of [u_charged] to be saved as 150000.
I can't find it even if I search for the query statement. Please help me. Thank you.
$query = "UPDATE userinfo
INNER JOIN chargeINFO ON (userinfo.u_id = chargeINFO.u_id)
SET userinfo.u_charged = chargeINFO.u_chargewait";
CodePudding user response:
In order to get the result 150000
from the original u_charged = 50000
and u_chargewait = 100000
, you need to add the two columns together, rather than just assigning one to the other. Then you can assign the result back to the column to update it.
UPDATE userinfo
INNER JOIN chargeINFO ON (userinfo.u_id = chargeINFO.u_id)
SET userinfo.u_charged = userinfo.u_charged chargeINFO.u_chargewait