Answer the question
In order to leave comments, you need to log in
Update request with condition?
Good afternoon!
Good people, tell me how in mysql it is possible to write an update request with a condition?
For example, if in field 1 then we replace it with 2, if 2 then we replace it with 1.
The field contains the letter “b” and “empty”, I need to swap, so to speak, the letter b is replaced by "empty", and "empty" is replaced by "b".
Answer the question
In order to leave comments, you need to log in
I would change in three requests through the third value, which is definitely not in this column.
Update table set field='c' where field='';
Update table set field='' where field='b';
Update table set field='b' where field='c';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question