I have a table which has been populated with incorrect data, so I need to switch some numbers around. I'm not sure if this would be the best way to go about it, but I'm thinking about using an UPDATE statement with multiple IF conditions. Something like:
UPDATE
`orders`
SET
`orderPriority` = 1
IF(`orderPriority` = 2)
OR
`orderPriority` = 2
IF(`orderPriority = 3)
OR
`orderPriority` = 3
IF(`orderPriority` = 1);
Obviously this doesn't work, but my SQL skills are lacking here. Any help is appreciated!!!
UPDATE orders
SET orderPriority = CASE WHEN orderPriority = 1 THEN 3
WHEN orderPriority = 2 THEN 1
WHEN orderPriority = 3 THEN 2
END
WHERE orderPriority IN (1,2,3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With