There is a table, T1 , in it you need to set the value of the field V2 to 'A3' , but only if this field was equal to 'A2' . You need to do this for all records whose V1 field is 'A1'

I tried it like this ... but something is already confused ...

 UPDATE `T1` SET `V2` = REPLACE(`V2`, "A2", "A3") FROM `T1` WHERE `V1` LIKE 'A1' 
  • 2
    UPDATE T1 SET V2 = IF(V2='A2', 'A3', V2) WHERE V1='A1' - vp_arth
  • Thank! It works! - Yuri Krupin

1 answer 1

Either I did not understand something, or this is done by a banal request.

 UPDATE `T1` SET `V2` = 'A3' WHERE `V1` = 'A1' AND `V2` = 'A2' 
  • I’m just doing this for the first time, and in the prompts only a SELECT or UPDATE query is separate, but at the same time, I haven’t seen any examples yet, and I haven’t figured out the English-speaking ... thanks - Yuri Krupin
  • @YuriKrupin I did not understand, why do you need SELECT ? - Anton Shchyrov
  • just didn't know how to do it - Yuri Krupin