I want to update all fields in a table based on another field having a condition being true, e.g.
Table1
field1 (string)
field2 (string)
field3 (condition to check)
field4 (field to update)
In table1, if field3 = "XYZ" then i would like field 4 to be updated with a string consisting of field1 & field2 ..
I've tried the following:
UPDATE table1
SET field4 = CONCAT(field1,field2)
Unfortunately this obviously replace all the field4 values and didn't do what I was looking for .. I've looked online for a better example of how I can accomplish this but no luck .. it's greek to me .. any help or direction is appreciated.
Unless I'm misunderstanding you, you want to use a WHERE clause:
UPDATE table1
SET field4 = CONCAT(field1,field2)
WHERE field3 = "XYZ"
Here is some information on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With