mardi 3 avril 2018

How to check if column contains and Id and then update it in sql?

I have a table as follows

Zoneid     |  Values
------------------
  1    |  a
  1    |  b  
  1    |  c
  1    |  d
  1    |  e
  2    |  a
  2    |  a
  2    |  c
  2    |  c
  2    |  e
  3    |  a
  3    |  c
  3    |  b
  3    |  d

I would like to update all values having Zoneid =1 to "completed" and ZoneId =3 to "failure", is there any if statement I could tried to do this? any

if(ZoneId = "1") Update Zones set Values = "completed";

syntax in mysql?

IMPORTANT

Iterating through every ZoneId is a must

Aucun commentaire:

Enregistrer un commentaire