我曾经写过一篇关于php 二进制打包的参数h和H搞错造成的数据录入错误。 对于已经录入的数据,如何修复呢。 有个高手同事写了以下的sql.
UPDATE table_name SET user_uuid_fixed = UNHEX(
CONCAT(
MID(HEX(user_uuid), 2, 1),
MID(HEX(user_uuid), 1, 1),
MID(HEX(user_uuid), 4, 1),
MID(HEX(user_uuid), 3, 1),
MID(HEX(user_uuid), 6, 1),
MID(HEX(user_uuid), 5, 1),
MID(HEX(user_uuid), 8, 1),
MID(HEX(user_uuid), 7, 1),
MID(HEX(user_uuid), 10, 1),
MID(HEX(user_uuid), 9, 1),
MID(HEX(user_uuid), 12, 1),
MID(HEX(user_uuid), 11, 1),
MID(HEX(user_uuid), 14, 1),
MID(HEX(user_uuid), 13, 1),
MID(HEX(user_uuid), 16, 1),
MID(HEX(user_uuid), 15, 1),
MID(HEX(user_uuid), 18, 1),
MID(HEX(user_uuid), 17, 1),
MID(HEX(user_uuid), 20, 1),
MID(HEX(user_uuid), 19, 1),
MID(HEX(user_uuid), 22, 1),
MID(HEX(user_uuid), 21, 1),
MID(HEX(user_uuid), 24, 1),
MID(HEX(user_uuid), 23, 1),
MID(HEX(user_uuid), 26, 1),
MID(HEX(user_uuid), 25, 1),
MID(HEX(user_uuid), 28, 1),
MID(HEX(user_uuid), 27, 1),
MID(HEX(user_uuid), 30, 1),
MID(HEX(user_uuid), 29, 1),
MID(HEX(user_uuid), 32, 1),
MID(HEX(user_uuid), 31, 1)
)
);
UPDATE table_name SET journey_fixed = UNHEX(
CONCAT(
MID(HEX(journey), 2, 1),
MID(HEX(journey), 1, 1),
MID(HEX(journey), 4, 1),
MID(HEX(journey), 3, 1),
MID(HEX(journey), 6, 1),
MID(HEX(journey), 5, 1),
MID(HEX(journey), 8, 1),
MID(HEX(journey), 7, 1),
MID(HEX(journey), 10, 1),
MID(HEX(journey), 9, 1),
MID(HEX(journey), 12, 1),
MID(HEX(journey), 11, 1),
MID(HEX(journey), 14, 1),
MID(HEX(journey), 13, 1),
MID(HEX(journey), 16, 1),
MID(HEX(journey), 15, 1),
MID(HEX(journey), 18, 1),
MID(HEX(journey), 17, 1),
MID(HEX(journey), 20, 1),
MID(HEX(journey), 19, 1),
MID(HEX(journey), 22, 1),
MID(HEX(journey), 21, 1),
MID(HEX(journey), 24, 1),
MID(HEX(journey), 23, 1),
MID(HEX(journey), 26, 1),
MID(HEX(journey), 25, 1),
MID(HEX(journey), 28, 1),
MID(HEX(journey), 27, 1),
MID(HEX(journey), 30, 1),
MID(HEX(journey), 29, 1),
MID(HEX(journey), 32, 1),
MID(HEX(journey), 31, 1)
)
);
佩服。