T
T
TechNOIR2018-12-13 16:46:19
MySQL
TechNOIR, 2018-12-13 16:46:19

SQL. How to do a bulk REPLACE?

Good afternoon.
How to do a bulk REPLACE on a specific column in MySQL using a single query?
It is necessary to change for example:
1 to 2
3 to 4
5 to 6
And there are a lot of such pairs
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sts, 2018-12-13
@TechNOIR

see the expression CASE WHEN THEN
ELSE

UPDATE `table` SET `uid` = CASE
    WHEN id = 1 THEN 2 
    WHEN id = 3 THEN 4
    WHEN id = 5 THEN 6
    ELSE uid
    END
WHERE id  in (1,2,3)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question