Suppose there is a data field education in my table profile, now I want to update education=’01’ where earlier education was ‘BA’ , similarly education=’02’ where education was ‘MD’
So I can do this task like this
update profile set education='01' where education='BA';
update profile set education='02' where education='MD';
My question is can I do this task in one command only like
update profile set education='01' where education='BA' and set education='02' where education='MD';
This syntax is wrong, please tell me is this possible and how ?
If it is not possible, than also please let me know about it…
You can use a
CASEstatement in theSETclause, but be careful to include anELSEcase which sets the column to its current value — otherwise, the rows that aren’t matched by the two cases will be set toNULL.