How do i use similiar to assign operator += in sql? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i use similiar to assign operator += in sql?

i can only think one way, SELECT FROM WHERE and save it in variable (PHP), add it, and UPDATE, done. the problem is, i need do it many times in one file, so, i scared it will not good to performance, can someone give me idea/your suggestion? anything is fine. #what i know is, mysql only have := as assign operator #may be it's just me, i try search at forum (like stackoverflow), but still not find it

17th Dec 2017, 6:07 AM
kito fool pace
kito fool pace - avatar
2 Answers
+ 1
i only test it at intepreter online, and it work, #ex: id int UPDATE test SET id=id+11 WHERE id=2 #never i think about it, i'm so stupid. #i too focus at mysql that only have := as assign operator
21st Dec 2017, 5:21 AM
kito fool pace
kito fool pace - avatar
+ 3
$a=3; $a+=4; //Solving it: $a=3+4 echo $a; Output: 7. Now $a is 7. += obtains the new value for a variable
17th Dec 2017, 1:47 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar